【c++】PAT (Advanced Level) 1005. Spell It Right (20)
2014-02-22 14:58
471 查看
1005. Spell It Right (20)
时间限制400 ms
内存限制
32000 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
其实是basic里面的程序,
#include <iostream> #include <string> using namespace std; int main() { string Str; string num[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int count=0,n=0,py,store[100],i;//store用来倒序输出存储的 cin>>Str; count=Str.length(); for( i=0;i<count;i++){ n=n+(Str[i]-'0'); } py=n%10; //cout<<n; i=0; //i用来计数 store[i]=py; while((n=n/10)!=0){ i++; store[i]=n%10; } cout<<num[store[i]]; i--; while(i>=0){ cout<<" "; cout<<num[store[i]]; i--; } cin>>n; return 0; }
相关文章推荐
- PAT-PAT (Advanced Level) Practise 1005. Spell It Right (20) (简单模拟题)【一星级】
- PAT (Advanced Level) 1005. Spell It Right (20) string转int,哈希
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- 【PAT】【Advanced Level】1005. Spell It Right (20)
- PAT(Advanced Level)1005. Spell It Right (20) 栈 int转string
- PAT (Advanced Level) 1005. Spell It Right (20)
- 【PAT (Advanced Level)】1005. Spell It Right (20)
- 1005. Spell It Right (20)——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1005 Spell It Right (20)
- 1005. Spell It Right (20)——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise - 1005. Spell It Right (20)
- PAT (Advanced Level) 1005. Spell It Right (20) 解题报告
- 【PAT Advanced Level】1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- PAT (Advanced Level) 1005. Spell It Right (20)
- [PAT (Advanced Level) ]1005. Spell It Right解题文档
- PAT(Advanced Level) 1005 - Spell It Right (水题)
- PAT (Advanced Level) Practise 1005 Spell It Right
- PAT (Advanced) 1005. Spell It Right (20)
- Pat(Advanced Level)Practice--1005(Spell It Right)