1005 Spell It Right
代码:
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main(){
string t;
char num[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
cin>>t;
string n=t;
string ss="";
int sum=0;
while(n.length()){
sum+=(n[n.length()-1]-'0');
n.erase(n.end() - 1);
}
while(sum){
int i=sum%10;
ss.insert(0,num[i]);
if(sum/10)
ss.insert(0," ");
sum/=10;
}
if(t!="0")
cout<<ss;
else
cout<<"zero";
}