1005. Spell It Right
来源:互联网 发布:听力打卡的软件 编辑:程序博客网 时间:2024/06/07 06:11
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:12345Sample Output:
one five
解题思路:这题很水,光看样例就懂了,给你一个数,将其所有的位数加起来,然后按照英文单词输出。。
代码如下:
#include<stdio.h>#include<math.h>#include<string.h>#define LL long longchar a[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};int main(){ char str[101]; int sum=0,j=0; scanf("%s",str); for(int i=0;str[i]!='\0';i++) sum+=str[i]-'0'; int t1=sum/100; int t2=sum%100/10; int t3=sum%10; if(t1!=0) printf("%s %s %s\n",a[t1],a[t2],a[t3]); else { if(t2==0) printf("%s\n",a[t3]); else printf("%s %s\n",a[t2],a[t3]); } return 0;}
0 0
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005.Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- pat 1005. Spell It Right
- 正则表达式基本语法
- 杭电ACM1009
- matlab命令行中双箭头消失怎么办
- ArrayList和LinkedList的时间复杂度
- [BZOJ Contest-2017省队十连测推广赛2·T3][BZOJ4256][DP][Tarjan]推箱子
- 1005. Spell It Right
- 深入理解Java异常类
- LinkedHashMap
- L2-001. 紧急救援
- Merge k sorted lists
- hdu 1285 拓扑排序起步
- 【Mysql】体系结构
- 青年创业急需代言人,微商能否扛旗冲锋
- UVA 120 Stacks of Flapjacks ——思路题