PAT1005.Spell It Right
来源:互联网 发布:js 计算一年共有几周 编辑:程序博客网 时间:2024/05/30 23:21
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
ps:简单的表值对应,注意sum==0的情况就好了。
#include<stdio.h>#include<string.h>
#define N 10000
char inStr[N];int outStr[N];
int main(){ char stander[][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; scanf("%s",inStr); int len=strlen(inStr); int i,sum=0; for(i=0;i<len;i++) sum+=inStr[i]-'0'; if( !sum ) { puts("zero"); return 0; } int pos=0; while( sum ) { outStr[pos++]=sum%10; sum/=10; } for(i=pos-1;i>=0;i--) printf("%s%c",stander[outStr[i]],i?' ':'\n');
return 0;}
- PAT1005.Spell It Right
- PAT1005. Spell It Right
- pat1005 Spell It Right
- PAT1005-Spell It Right
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005 Spell It Right 大水题
- 1005. Spell It Right
- 1005. Spell It Right
- PAT_1005: Spell It Right
- 1005. Spell It Right
- 1005.Spell It Right
- 1005. Spell It Right
- Spell It Right
- Spell It Right
- Altium designer 技巧
- iphone聊天用几种图形(表情)与文字混排的实现与比较
- 企业云计算部署四步走
- 浅析tomcat nio 配置
- web页面布局控制
- PAT1005.Spell It Right
- ubuntu 12.04 家目录下存在隐藏文件.goutputstream-***
- uboot参数解析和NFS服务器的配置
- cygwin 编译ffmpeg 之android.mk
- 应用程序之间互相通讯的几种方法
- 转Class.forName详解
- ACE
- 各种笔试面试经历小总结(1)
- 浙大考研实验室面试---电话面试