-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5_for_loop.cpp
More file actions
57 lines (50 loc) · 956 Bytes
/
5_for_loop.cpp
File metadata and controls
57 lines (50 loc) · 956 Bytes
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
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <cstdio>
using namespace std;
/*
Sample input:
8
11
Sample output:
eight
nine
even
odd
*/
string getNumberAsText(int i) {
if(i == 1)
return "one";
else if(i == 2)
return "two";
else if(i == 3)
return "three";
else if(i == 4)
return "four";
else if(i == 5)
return "five";
else if(i == 6)
return "six";
else if(i == 7)
return "seven";
else if(i == 8)
return "eight";
else if(i == 9)
return "nine";
return "";
}
int main() {
// Complete the code.
int a, b;
scanf("%i\n%i", &a, &b);
for(int i = a; i <= b; i++) {
if(i > 9) {
if(i % 2 == 0)
printf("even\n");
else
printf("odd\n");
continue;
}
cout << getNumberAsText(i) << endl;
}
return 0;
}