1005. Spell It Right (20)

时间限制
400 ms
内存限制
65536 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>
#include<string.h>
int main()
{
char s[1000];
int t[1000],sum,u[1000],i,j,k,n;
while(scanf("%s",s)!=EOF)
{
k=strlen(s);
sum=0;
for(i=0;i<k;i++)
{
t[i]=s[i]-'0';
sum+=t[i];
}
if(sum==0)
printf("zero\n");
else
{
j=0; while(sum!=0)
{
u[j++]=sum%10;
sum/=10;
}
n=0;
for(i=j-1;i>=0;i--)
{
while(n++)
{
printf(" ");
break;
}
if(u[i]==0)
printf("zero");
else if(u[i]==1)
printf("one");
else if(u[i]==2)
printf("two");
else if(u[i]==3)
printf("three");
else if(u[i]==4)
printf("four");
else if(u[i]==5)
printf("five");
else if(u[i]==6)
printf("six");
else if(u[i]==7)
printf("seven");
else if(u[i]==8)
printf("eight");
else if(u[i]==9)
printf("nine");
}
printf("\n");
}
}
return 0;
}

PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏的更多相关文章

  1. PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  2. PAT甲 1002. A+B for Polynomials (25) 2016-09-09 22:50 64人阅读 评论(0) 收藏

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  3. hdu3333 Turing Tree 2016-09-18 20:53 42人阅读 评论(0) 收藏

    Turing Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  4. PAT甲 1001. A+B Format (20) 2016-09-09 22:47 25人阅读 评论(0) 收藏

    1001. A+B Format (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Calculate ...

  5. PAT甲 1007. Maximum Subsequence Sum (25) 2016-09-09 22:56 41人阅读 评论(0) 收藏

    1007. Maximum Subsequence Sum (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...

  6. 哈希-Snowflake Snow Snowflakes 分类: POJ 哈希 2015-08-06 20:53 2人阅读 评论(0) 收藏

    Snowflake Snow Snowflakes Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 34762 Accepted: ...

  7. House Robber 分类: leetcode 算法 2015-07-09 20:53 2人阅读 评论(0) 收藏

    DP 对于第i个状态(房子),有两种选择:偷(rob).不偷(not rob) 递推公式为: f(i)=max⎧⎩⎨⎪⎪{f(i−1)+vali,f(i−2)+vali,robi−1==0robi−1 ...

  8. ZOJ2417 Lowest Bit 2017-04-18 20:53 38人阅读 评论(0) 收藏

    Lowest Bit Time Limit: 2 Seconds      Memory Limit: 65536 KB Given an positive integer A (1 <= A ...

  9. 如何在hadoop中控制map的个数 分类: A1_HADOOP 2015-03-13 20:53 86人阅读 评论(0) 收藏

    hadooop提供了一个设置map个数的参数mapred.map.tasks,我们可以通过这个参数来控制map的个数.但是通过这种方式设置map的个数,并不是每次都有效的.原因是mapred.map. ...

随机推荐

  1. ASP.NETAutocomplete control

    分享一个Ajax autocomplete control, 原文链接:http://forums.asp.net/t/1157595.aspx 首先,引入ScriptManager <asp: ...

  2. CentOS7使用yum详细搭建zabbix3.2过程

    本文引用于:http://blog.csdn.net/s3275492383/article/details/62417210 一.准备搭建环境: 1.系统:CentOS7 2.默认有使用linux服 ...

  3. 导出 java.io.IOException: 权限不够

    项目原先都是开发使用root账号登陆服务器,人肉部署. 今天改成了自动部署,部署之后发现导出用不了了,查看服务器日志提示: 查看项目启动用户是app,推断是app用户的权限不够,导致导出无法在服务器创 ...

  4. dubbo 多协议和多注册中心

    一.配置dubbo多协议模式 1.默认协议 Dubbo缺省协议采用单一长连接和NIO异步通讯,适合于小数据量大并发的服务调用,以及服务消费者机器数远大于服务提供者机器数的情况.Dubbo缺省协议不适合 ...

  5. 运行Maven项目时出现invalid LOC header (bad signature)

    为Maven小白,今天这问题困扰了我好久,经过多次在网上查询,终于找到了原因.明明一个小问题却耗费很多时间,着实不应该,所以必须记录一下. 报错信息如下:   对话框: 控制台: <span s ...

  6. 双活部署前收集EMC存储设备信息

    以0.68服务器为例 1.拷贝emcgrab_Linux_v4.7.10.tar到linux服务器并将其解压到/tmp目录下 tar -xvf emcgrab_Linux_v4.7.10.tar -C ...

  7. 配置Tomcat 7 Gzip

    <Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" ...

  8. dede的cfg_keywords和cfg_description无法显示

    问题:在生成html文件时,网页的keywords和description的content为空,但后台显示这两项是有值的.   解决方案: 1.设置 系统->系统基本参数->站点根网址 设 ...

  9. Tortoise SVN 使用笔记

    最近一个项目,团队使用的是SVN来控制版本,所以顺便学习下SVN的知识.在Windows上,肯定是用图形化客户端Tortoise SVN在加速我们的工作. 首先,在一个准备用在工作目录的文件夹下,点击 ...

  10. 【转】Hadoop HDFS分布式环境搭建

    原文地址  http://blog.sina.com.cn/s/blog_7060fb5a0101cson.html Hadoop HDFS分布式环境搭建 最近选择给大家介绍Hadoop HDFS系统 ...