PAT1005. Spell It Right

来源:互联网 发布:怎样才能做淘宝客推广 编辑:程序博客网 时间:2024/05/16 18:13
#include<string>#include<vector>#include<iostream>using namespace std;char *p[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};int main(){  int total(0);  for(char c;cin>>c;)total+=c-'0';  if(total){    vector<int>ret;    while(total){ret.push_back(total%10);total/=10;}    for(auto it=ret.rbegin();it!=ret.rend();++it){      if(it!=ret.rbegin())cout<<' ';      cout<<p[*it];}  }//if  else cout<<"zero";  return 0;}

0 0