pat 1005. Spell It Right (20)
2017-12-11 13:07
351 查看
简单题
#include <iostream> #include <cstring> using namespace std; #include <stack> int main(){ ios::sync_with_stdio(false); stack<int>s; string a; string res[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"}; int sum=0; cin>>a; for(int i=0;i<a.size();i++){ sum += a[i]-'0'; } if(!sum) s.push(0); int tmp; while(sum){ tmp = sum%10; sum /= 10; s.push(tmp); } while(s.size()){ tmp = s.top(); s.pop(); cout<<res[tmp]; if(s.size()) cout<<" "; } return 0; }
相关文章推荐
- PAT (Advanced Level) 1005. Spell It Right (20) string转int,哈希
- PAT Advanced 1005. Spell It Right (20) (C语言实现)
- PAT甲级 1005. Spell It Right (20)
- PAT---1005. Spell It Right (20)
- PAT: 1005. Spell It Right (20)
- PAT (Advanced Level) Practise - 1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005 Spell It Right (20)
- 【c++】PAT (Advanced Level) 1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20) 【字符串】
- PAT-1005 Spell It Right (20)
- PAT(Advanced Level)1005. Spell It Right (20) 栈 int转string
- PAT 1005 Spell It Right (20)(字符转换)
- PAT-A 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 Advanced Level】1005. Spell It Right (20)
- PAT甲级-1005. Spell It Right (20)各位之和
- PAT(甲级)1005. Spell It Right (20)