前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PAT Advanced 1005

PAT Advanced 1005

作者头像
chain
发布2018-08-02 15:13:35
2680
发布2018-08-02 15:13:35
举报

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;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013年10月23日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1005. Spell It Right (20)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档