[PAT] 1005 Spell It Right (20)
2017-10-22 15:50
134 查看
题意是给你几个数,让你输出他们求和后的每个数的英文,如12345输出 one five
//已AC代码 #include<bits/stdc++.h> using namespace std; stack<int> s; int main() { string b[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; char a[100860]={'$'}; while(~scanf("%s",&a)) { int sum=0; int count=0; int n=strlen(a); for(int i=0;i<n;i++) { sum+=(a[i]-'0'); } if(sum==0) { cout<<"zero"<<endl; continue; } while(sum) { s.push(sum%10); count++; sum=sum/10; } while(!s.empty()) { int tmp=s.top(); if(count==1) cout<<b[tmp]<<endl; else cout<<b[tmp]<<" "; count--; s.pop(); } } }
相关文章推荐
- PAT1005. Spell It Right (20)
- 1005. Spell It Right (20)——PAT (Advanced Level) Practise
- PAT-A 1005. Spell It Right (20)
- 1005. Spell It Right (20)——PAT (Advanced Level) Practise
- 浙江大学PAT上机题解析之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)
- PAT1005. Spell It Right (20)
- PAT(甲级)1005. Spell It Right (20)
- 【PAT甲级】1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20) 【字符串】
- PAT 甲级 1005. Spell It Right (20)
- PAT甲级.1005. Spell It Right (20)
- PAT-PAT (Advanced Level) Practise 1005. Spell It Right (20) (简单模拟题)【一星级】
- PAT (Advanced Level) 1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005. Spell It Right (20)
- PAT1005. Spell It Right (20)