您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: