-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFor Loop.cpp
47 lines (40 loc) · 948 Bytes
/
For Loop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
https://www.hackerrank.com/challenges/c-tutorial-for-loop/copy-from/189280405
*/
#include<iostream>
#include <cstdio>
using namespace std;
int main() {
int a,b;
int n=0;
string intMap[9]= {"one", "two","three","four","five","six","seven","eight","nine"};
cin>>a>>b;
if ((a<=9)&&(b<=9)){
for(n=a;n<=b;n++){
cout << intMap[n-1]<<endl;
} }
else if ((a<=9)&&(b>9)){
for(n=a;n<=9;n++){
cout<<intMap[n-1]<<endl;
}
for(n=10;n<=b;n++){
if (n%2==0){
cout<<"even"<<endl;
}
else {
cout<<"odd"<<endl;
}
}
}
else {
for(n=a;n<=b;n++){
if (n%2==0){
cout<<"even"<<endl;
}
else {
cout<<"odd"<<endl;
}
}
}
return 0;
}