代码:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char dic[30][20]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve",
"thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty","a",
"both","another","first","second","third"};//对应
int di[30]={0,1,4,9,16,25,36,49,64,81,00,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};
char s[100];
int a[12];
int main()
{
int i,j,cnt=0;
int flag=0;
for(i=1; i<=6; i++)
{
scanf("%s",s);
for(j=1; j<=26; j++)
{
if(strcmp(s,dic[j])==0)
{
a[cnt++]=di[j];
break;
}
}
}
sort(a,a+cnt);
for(i=0; i<cnt; i++)
{
if(flag)
{
printf("%.2d",a[i]);
}else
{
if(a[i])
{
printf("%d",a[i]);
flag=1;
}
}
}
if(!flag)
cout<<0;
return 0;
}
/*
14 3 9 2 5 4 0 0 0 0 0 0
1 1 3 4 9 2 8 2 8 8 8 7 1 9
*/