1005. Spell It Right (20)水题
2015-08-26 22:45
375 查看
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 <cstdio> # include <iostream> # include <cstdlib> char Num[1000]; const char *digit[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"}; int main() { scanf("%s",Num); int sum = 0; for (int i=0;Num[i]!='\0';i++) sum += Num[i] - '0'; int s[1000],e=0; while (sum>0) { s[e++] = sum%10; sum /= 10; } printf("%s",digit[s[--e]]); while (e--) { if (e<0) break; printf(" %s",digit[s[e]]); } printf("\n"); return 0; }
相关文章推荐
- Qt知识点、疑难杂症的治疗
- Linux磁盘管理与文件系统
- TCP/IP
- HDU2955Robberies (0-1背包问题)
- WinCE中串口驱动及接口函数介绍
- hdoj 2016 数据的交换输出
- 黑马程序员--Java集合框架(三)
- Java引用总结--StrongReference、SoftReference、WeakReference、PhantomReference
- 第37讲:List的foldLeft、foldRight、sort操作代码实战
- sqlserver中的存储过程 函数 事物 索引及视图
- 07 java.lang.StringBuilder
- 类的继承和多态
- 软件随想
- 树莓派修改更新源
- Android中如何查看内存
- hdu 5379 Mahjong tree(构造)
- POJ 2762 强连通分量 Tarjan + 缩点
- C# httpwebrequest访问HTTPS错误处理
- LRU算法
- [LeetCode]#13 3sum