查看原题目请点我
解题思路:主要是字符串的处理,首先求和,然后把求得的数字转化为数字,再用对应的数字映射导对应的拼音进行输出。
#include<cstdio>
#include<cstring>
char stt[][8]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
int main(){
char str[110]={0};
scanf("%s",str);
int len=strlen(str);
int sum=0;
for(int i=0;i<len;i++){
sum+=str[i]-'0';
}
int ss[110]={0};
int k=0;
do{
ss[k++]=sum%10;
sum/=10;
}while(sum!=0);
for(int i=k-1;i>=0;i--){
printf(i==k-1?"%s":" %s",stt[ss[i]]);
}
return 0;
}