-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexec4-6.cpp
More file actions
31 lines (29 loc) · 733 Bytes
/
exec4-6.cpp
File metadata and controls
31 lines (29 loc) · 733 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
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
vector<string> numbers = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int d;
string s;
if (cin >> d) {
if (d >= 0 && d <= 9)
cout << numbers[d] << endl;
else
cout << "not a number I know\n";
}
else {
cin.clear();
cin >> s;
bool found = false;
for (int i = 0; i < numbers.size(); ++i)
if (s == numbers[i]) {
cout << i << endl;
found = true;
break;
}
if (!found)
cout << "not a number I know\n";
}
return 0;
}