1005. Spell It Right (20)
时间限制 400 ms
内存限制 32000 kB
代码长度限制 16000 B
判题程序Standard
作者CHEN, Yue
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.
Input Specification:
Each input file contains one test case. Each case occupies one line which contains an N (<= 10100).
Output Specification:
For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.
Sample Input:
12345
Sample Output:
one five
#include<stdio.h>
char a[10][6]={"zero","one","two","three","four","five","six","seven","eight","nine"};
/*递归的从左至右输出各个位*/
void b(int sum,int count)
{
count++;
if(sum/10 !=0 )
b(sum/10,count);
if(count==1)
printf("%s",a[sum%10]);
else
printf("%s ",a[sum%10]);
}
int main()
{
char n[102];//10的100次方最大存储空间
int i=0,sum=0,r=1;
scanf("%s",n);
while(n[i]!='\0')
sum += n[i++]-48 ;
b(sum,0);
return 0;
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有