1005 Spell It Right (20 point(s))
将各位加起来的数,按英语一个一个单词输出
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
const int inf_int = 1e9;
char s[maxn];int len;
string name[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
vector<string> ans;
int main(){
scanf("%s",s+1);len = strlen(s+1);
int sum = 0;
for(int i = 1;i<=len;i++){
sum += (s[i]-'0');
}
if(sum == 0) puts("zero");
else{
while(sum) {
ans.push_back(name[sum%10]);
sum/=10;
}
reverse(ans.begin(),ans.end());
int sp = 1;
for(auto s:ans){
if(sp) sp = 0;else putchar(' ');
cout<<s;
}
}
return 0;
}