思路
//思路:开数组:字符数组 和 取模数组
//然后根据题目输入6个单词,则直接用for循环输入
//然后寻找是否在字符数组中出现
//最后要注意的:第一位不能有前导0
//方法:除了第一位,其他都补足两位
源码
#include<bits/stdc++.h>
//思路:开数组:字符数组 和 取模数组
//然后根据题目输入6个单词,则直接用for循环输入
//然后寻找是否在字符数组中出现
//最后要注意的:第一位不能有前导0
//方法:除了第一位,其他都补足两位
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};
unsigned long long int a[10],top,flag;
int i,j;
char s[100];
int main(){
for(int i=0;i<6;i++){
cin>>s;
for(int j=1;j<=26;j++){
if(!strcmp(s,dic[j])){
a[++top]=di[j];
break;
}
}
}
sort(a,a+1+top);
for(int i=1;i<=top;i++){
if(flag){
printf("%.2d",a[i]); //不足两位,左边补0
}
else{
if(a[i]){
printf("%d",a[i]);
flag=1;
}
}
}
if(!flag) cout<<0<<endl;
return 0;
}