chenxuanting @ 2019-08-20 17:21:21
代码如下:
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string word[6];
string num[6];
int ans=0;
int main()
{
for(int i=0;i<6;i++){
cin>>word[i];
num[i]="99";
}
word[5].erase(word[5].find('.'));
for(int i=0;i<6;i++){
if(word[i]=="one"||word[i]=="a"||word[i]=="another"||word[i]=="first"){
num[i]=="01";
ans+=1;
continue;
}
if(word[i]=="two"||word[i]=="both"||word[i]=="second"){
num[i]=="04";
ans+=1;
continue;
}
if(word[i]=="three"||word[i]=="third"){
num[i]=="09";
ans+=1;
continue;
}
if(word[i]=="four"){
num[i]=="16";
ans+=1;
continue;
}
if(word[i]=="five"||word[i]=="fifteen"){
num[i]=="25";
ans+=1;
continue;
}
if(word[i]=="six"){
num[i]=="36";
ans+=1;
continue;
}
if(word[i]=="seven"){
num[i]=="49";
ans+=1;
continue;
}
if(word[i]=="eight"){
num[i]=="64";
ans+=1;
continue;
}
if(word[i]=="nine"){
num[i]=="81";
ans+=1;
continue;
}
if(word[i]=="ten"||word[i]=="twenty"){
num[i]=="00";
ans+=1;
continue;
}
if(word[i]=="eleven"){
num[i]=="21";
ans+=1;
continue;
}
if(word[i]=="twelve"){
num[i]=="44";
ans+=1;
continue;
}
if(word[i]=="thirteen"){
num[i]=="69";
ans+=1;
continue;
}
if(word[i]=="fourteen"){
num[i]=="96";
ans+=1;
}
if(word[i]=="sixteen"){
num[i]=="56";
ans+=1;
continue;
}
if(word[i]=="seventeen"){
num[i]=="89";
ans+=1;
continue;
}
if(word[i]=="eighteen"){
num[i]=="24";
ans+=1;
continue;
}
if(word[i]=="nineteen"){
num[i]=="61";
ans+=1;
continue;
}
}
sort(num,num+6);
if(ans!=0){
for(int i=1;i<ans;i++){
num[0]+=num[i];
}
int count1=0;
while(count1!=(2*ans-1)&&num[0][count1]=='0'){
count1++;
}
for(int i1=count1;i1<(2*ans);i1++){
cout<<num[0][i1];
}
}else{
cout<<"0";
}
return 0;
}
希望更丰富的展现?使用Markdown
by chenxuanting @ 2019-08-21 16:52:40
已经过了,不用了
by JeffWang2019 @ 2019-08-27 22:53:43
哎,白跑来一趟