完美的一道笔试题目
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
char str[10];
int main()
{
map<int,string>Q;
Q[0]="ling";
Q[1]="yi";
Q[2]="er";
Q[3]="san";
Q[4]="si";
Q[5]="wu";
Q[6]="liu";
Q[7]="qi";
Q[8]="ba";
Q[9]="jiu";
Q[100]="bai";
Q[10]="shi";
while(~scanf("%s",str))
{
int len=strlen(str);
int i;
for( i=0;i<len;i++)
if(str[i]!='0')
break;
for(int j=0;j<len-i;j++)
str[j]=str[j+i];
len-=i;
if(len>3)
continue;
if(len==3)
{
cout<<Q[str[0]-'0'];
cout<<Q[100];
if((str[1]=='0' && str[2]=='0') )
{
cout<<endl;
}
else if(str[1]=='0' && str[2]!='0')
{
cout<<Q[str[1]-'0']<<Q[str[2]-'0']<<endl;
}
else if(str[1]!='0' && str[2]=='0')
{
cout<<Q[str[1]-'0']<<Q[10]<<endl;
}
else
{
cout<<Q[str[1]-'0']<<Q[10]<<Q[str[2]-'0']<<endl;
}
}
else if(len==2)
{
if (str[0]=='1' && str[1]!='0')
cout<<Q[10]<<Q[str[1]-'0']<<endl;
else{
cout<<Q[str[0]-'0']<<Q[10];
if(str[1]!='0')
cout<<Q[str[1]-'0'];
cout<<endl;
}
}
else
cout<<Q[str[0]-'0']<<endl;
}
return 0;
}