题目原址:http://www.patest.cn/contests/pat-a-practise/1005
#include<stdio.h>
#include<string.h>
int main(){
char str[110];
int i, num, ans[20];
scanf("%s", str);
num = 0;
for(i = 0; i < strlen(str); i++){
num += str[i] - '0';
}
if(!num){
printf("zero\n");
return 0;
}
memset(ans, 0, sizeof(ans));
i = 0;
while(num){
ans[i++] = num % 10;
num /= 10;
}
for(i--; i >= 0; i--){
switch(ans[i]){
case 0:
printf("zero");
break;
case 1:
printf("one");
break;
case 2:
printf("two");
break;
case 3:
printf("three");
break;
case 4:
printf("four");
break;
case 5:
printf("five");
break;
case 6:
printf("six");
break;
case 7:
printf("seven");
break;
case 8:
printf("eight");
break;
case 9:
printf("nine");
break;
}
if(i > 0)
printf(" ");
else
printf("\n");
}
return 0;
}