-
For Loop코딩 테스트/HackerRank 2021. 9. 16. 23:44
https://www.hackerrank.com/challenges/c-tutorial-for-loop/problem
For Loop | HackerRank
Learn how to use for loop and print the output as per the given conditions
www.hackerrank.com
#include <iostream> #include <cstdio> using namespace std; string numbers[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; int main() { // Complete the code. int num, sum; cin >> num >> sum; for (int i = num; i <= sum; i++) { if (i % 10 && i < 10) cout << numbers[i] << endl; else if (i % 2 == 0 && i > 9) cout << "even" << endl; else cout << "odd" << endl; } return 0; }
'코딩 테스트 > HackerRank' 카테고리의 다른 글
Functions (0) 2021.09.15 Pointer (0) 2021.09.14 Print the Elements of a Linked List (0) 2021.09.13