momo36524 @ 2024-03-21 10:12:50
#include<stdio.h>
#include<string.h>
int main(void){
char input[105];
int val[6];
int i,j,k,m,temp,ans=0;
char str_check[20][10]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
gets(input);
for(i=0,j=0;i<20;i++){
if(strstr(input,str_check[i])!=NULL){
val[j]=((i+1)*(i+1))%100;
j++;
}
}
for(k=1;k<=(j-1);k++){
for(m=0;m<=(j-k);m++){
if(val[m]>val[m+1]){
val[m]=temp;
val[m]=val[m+1];
val[m+1]=temp;
}
}
}
for(k=0;k<j;k++){
if(val[k]>9)
ans=(ans*100)+val[k];
else ans=(ans*10)+val[k];
}
printf("%d",ans);
return 0;
}
by momo36524 @ 2024-03-21 16:05:39
调试了好久发现自己一开始没看懂题目 现在终于AC了OVO
#include<stdio.h>
#include<string.h>
int main(void){
char input[105];
int val[6];
int i,j,k,m,temp,ans=0;
char str_check[26][10]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"," a ","another","first","both","second","third"};
gets(input);
for(i=0,j=0;i<26;i++){
if(strstr(input,str_check[i])!=NULL){
if(i<20){
val[j]=((i+1)*(i+1))%100;
j++;
}
else if(i==20||i==21||i==22){
val[j]=(1*1)%100;
j++;
}
else if(i==24||i==23){
val[j]=(2*2)%100;
j++;
}
else if(i==25){
val[j]=(3*3)%100;
j++;
}
}
}
if(j==0){
printf("0");
return 0;
}
for(k=1;k<=(j-1);k++){
for(m=0;m<(j-k);m++){
if(val[m]>val[m+1]){
temp=val[m];
val[m]=val[m+1];
val[m+1]=temp;
}
}
}
for(k=0;k<j;k++){
if(k>0){
printf("%02d",val[k]);
}
else printf("%d",val[k]);
}
return 0;
}