// 1005. Spell It Right.cpp: 主项目文件。
#include "stdafx.h"
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iostream>
using namespace std;
map<int,string> cmap;
void operate(int sum){
if(sum==0){
puts("zero");
return;
}
int aa[4],cnt=0;
memset(aa,0,sizeof(aa));
while(sum){
aa[cnt++]=sum%10;
sum/=10;
}
for(int i=cnt-1;i>=0;i--){
if(i!=cnt-1)
cout<<" ";
cout<<cmap[aa[i]];
}
cout<<endl;
}
int main()
{
const int N=103;
char str[N];
cmap[0]="zero";cmap[1]="one";cmap[2]="two";cmap[3]="three";
cmap[4]="four";cmap[5]="five";cmap[6]="six";cmap[7]="seven";
cmap[8]="eight";cmap[9]="nine";
while(gets(str)){
int sum=0;
for(int i=0;str[i];i++)
sum+=str[i]-'0';
operate(sum);
}
return 0;
}
1005. Spell It Right
最新推荐文章于 2024-05-17 16:45:04 发布