1005. Spell It Right (20)
2016-11-30 17:06
357 查看
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<string> #include<algorithm> #include<sstream> using namespace std; int main() { string num[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"}; int count=0; string s; cin >> s; stringstream temp; string::iterator it; for (it = s.begin(); it != s.end(); it++) count += *it - '0'; temp << count; s.clear(); temp >> s; for (it = s.begin(); it != s.end(); it++) { cout << num[*it - '0']; if ((it+1) != s.end()) cout << " "; } }
相关文章推荐
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- 【PAT】1005. Spell It Right (20)
- PAT: 1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20) 【字符串】
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)(to_string)
- [PAT甲级]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)
- 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-Java-1005-Spell It Right (20)
- 1005. Spell It Right (20)