We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. C++
  3. Introduction
  4. For Loop
  5. Discussions

For Loop

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • creeper4004
    2 months ago+ 0 comments

    It cant get better

    #include <iostream>
    #include <vector>
    
    int main()
    {
        std::vector<std::string> words = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
        int begin, end;
        std::cin >> begin >> end;
        for (int i = begin; i <= end; ++i)
        {
            if (i <= 9)
                std::cout << words[i] << std::endl;
            else
                std::cout << (i % 2 == 0 ? "even" : "odd") << std::endl;
        }
        return 0;
    }
    
    1|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy