您的位置:首页 > 其它

1005. Spell It Right (20)

2017-02-18 10:01 288 查看
https://www.patest.cn/contests/pat-a-practise/1005

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
string SpellRight(int i) {
switch (i) {
case 0:return "zero";
break;
case 1:return "one";
break;
case 2:return "two";
break;
case 3:return "three";
break;
case 4:return "four";
break;
case 5:return "five";
break;
case 6:return "six";
break;
case 7:return "seven";
break;
case 8:return "eight";
break;
}
return "nine";
}
int main() {
char N[101];
cin >> N;
int temp = 0;
int len = strlen(N);
string ma;
for (int i = 0; i < len; i++) {
temp += (N[i] - '0');
}
ma = SpellRight(temp%10);
//five
//12345
temp /= 10;
//
while (temp) {
ma = " " + ma;
ma = SpellRight(temp % 10) + ma;
temp /= 10;
}
cout << ma << endl;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: