样例不过
查看原帖
样例不过
1025958
511_Juruo_wyk楼主2023/12/6 21:59
#include<bits/stdc++.h>
using namespace std;
const int N = 26;
pair<string,int>p[N]={{"one",1},{"two",4},{"three",9},{"four",16},{"five",25},{"six",36},{"seven",49},{"eight",64},{"nine",81},
                      {"ten",0},{"eleven",21},{"twelve",44},{"tirteen",69},{"fourteen",96},{"fifteen",25},{"sixteen",56},
                      {"seventeen",89},{"eighteen",24},{"nineteen",61},{"twenty",0},{"a",1},{"both",4},{"another",1},
                      {"first",1},{"second",4},{"third",9}};
int num[10],top;
int member(string s){
    for(int i=0;i<N;i++)
        if(s==p[i].first)return p[i].second;
    throw s;
}
int main(){
    string s;
    for(int i=1;i<=6;i++){
        cin>>s;
        try {num[++top]=member(s);}
        catch(string){top--;}
    }
    sort(num+1,num+1+top);
    bool flag=true;
    for(int i=2;i<=top;i++){
        if(flag&&num[i]!=0)cout<<num[i],flag=false;
        else printf("%02d",num[i]);
    }
    return 0;
}

2023/12/6 21:59
加载中...