1005. Spell It Right (20)
2016-02-10 22:18
288 查看
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 <iostream> #include <vector> #include <string> #include <stdio.h> using namespace std; string eng[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int main(){ string str; cin>>str; int sum=0; for (char a : str) sum+=a-'0'; char *p=new char[10]; sprintf(p, "%d",sum); str=p; delete p; for (int i=0; i<str.size(); i++) { cout<<eng[str[i]-'0']; if(i==str.size()-1) cout<<endl; else cout<<" "; } return 0; }
相关文章推荐
- 【HDOJ】4328 Cut the cake
- 当phantomJS遇上Requests
- 文件系统管理
- 优先级队列——PriorityQueue
- 1004. Counting Leaves (30)
- 磁盘管理
- PyMySQL与Django的结合
- 队列单向
- 1003. Emergency (25)
- HDU 3853 LOOPS 概率DP 期望
- 机械键盘科普知识
- 1002. A+B for Polynomials (25)
- JavaScript创建对象之稳妥构造函数模式(七)
- 待解决
- 1001. A+B Format (20)
- [LeetCode]53. Maximum Subarray
- android 中的Uri详解
- [bzoj1806] [ioi2007]Miners 矿工配餐
- #学习笔记#(38)js轮播图
- Android开发学习之路--UI之ListView