您的位置:首页 > 其它

1005. Spell It Right (20)

2017-04-06 14:35 447 查看


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
char numToEng[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main(){
char str[102];
while(scanf("%s",str)!=EOF){
int sum=0;
int len=strlen(str);
for(int i=0;i<len;i++)
sum+=str[i]-'0';
stack<int> S;
do{
S.push(sum%10);
sum /= 10;
}while(sum);
while(!S.empty()){
if(S.size()>1)
printf("%s ",numToEng[S.top()]);
else
printf("%s",numToEng[S.top()]);
S.pop();
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: