-
Notifications
You must be signed in to change notification settings - Fork 0
/
1005_Spell_It_Right.cpp
73 lines (63 loc) · 1.08 KB
/
1005_Spell_It_Right.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <string>
using namespace std;
void digit_to_En(int x)
{
switch (x)
{
case 1:
cout << "one";
break;
case 2:
cout << "two";
break;
case 3:
cout << "three";
break;
case 4:
cout << "four";
break;
case 5:
cout << "five";
break;
case 6:
cout << "six";
break;
case 7 :
cout << "seven";
break;
case 8:
cout << "eight";
break;
case 9:
cout << "nine";
break;
case 0:
cout << "zero";
break;
default:
break;
}
return ;
}
int main()
{
string num;
cin >> num;
int first_digit = num[0] - '0';
long sum = 0;
for (int i = 0; i < num.length(); ++i)
{
int n = num[i] - '0';
sum += n;
}
string sum_str = to_string(sum);
digit_to_En(sum_str[0] - '0');
for (int i = 1; i < sum_str.length(); ++i)
{
int n = sum_str[i] - '0';
cout << " ";
digit_to_En(n);
}
return 0;
}