开心刷题王 @ 2018-09-15 09:48:10
而且这个if(m[0]='a'&&!m[1])如果放在for循环之前,为什么只输出1
using namespace std;
int a[6],j=0;
int main(){
string m;
string str[26]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","both","another", "first", "second","third"};
while(1){
cin>>m;
if(m[0]=='.') break;
if(m[0]<=97) m[0]+=32;
for(int i=0;i<26;i++){
if(m==str[i]){
if(i==22) {
a[j]=1;
j++;
cout<<a[j]<<endl;
}
else if(i==20||i==23) {
a[j]=4;
j++;
}
else if(i==21||i==24) {
a[j]=9;
j++;
}
else{
a[j]=(i+1)*(i+1)%100;
j++;
}
}
}
if(m[0]='a'&&!m[1]){
a[j]=1;
j++;
}
}
sort(a,a+j);
cout<<a[0];
for(int i=1;i<j;i++){
if(a[i]<10) cout<<0<<a[i];
else cout<<a[i];
}
}
by 镉八君 @ 2018-09-15 10:17:04
希望更丰富的展现?使用Markdown
by 开心刷题王 @ 2018-09-16 10:31:12
@镉八君 还是没找到为什么错了