PAT甲级1005
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
int s[1000]={0};
string m;
cin>>m;
int n=0;
int sum=0;
if(m[0]=='0'){
n=1;
s[0]=0;
}else{
for(int i=0;i<m.length();i++){
sum+=m[i]-'0';
}
while(sum>0){
s[n]=sum%10;
sum=sum/10;
n++;
}
}
for(int i=n-1;i>=0;i--){
switch (s[i]){
case 0: cout<<"zero"; break;
case 1: cout<<"one"; break;
case 2: cout<<"two"; break;
case 3: cout<<"three"; break;
case 4: cout<<"four"; break;
case 5: cout<<"five"; break;
case 6: cout<<"six"; break;
case 7: cout<<"seven"; break;
case 8: cout<<"eight"; break;
case 9: cout<<"nine"; break;
}
if(i!=0){
cout<<" ";
}
}
}
注意:1. 零的问题;2.由于数字较大,long long int 类型都不能满足,应用string来解决!!!