这第一篇题解的输入好像有问题,卡在while里出不来,我修改了一下,本蒟蒻第一篇评论,希望能帮到大家,以下是代码:
#include<bits/stdc++.h>
using namespace std;
string str[1001];
int main(){
string s;
getline(cin,s);
int a=0;
for(int i=0;i<s.size();i++){
if(s[i]==' '){
a++;
continue;
}
str[a]+=s[i];
}
for(int i = a; i >= 0; i--) {
for(int j = 0; j < (int)str[i].size(); j++) {
if(str[i][j] >= 'a' && str[i][j] <= 'z') str[i][j] -= 'a' - 'A';
else if(str[i][j] >= 'A' && str[i][j] <= 'Z') str[i][j] -= 'A' - 'a';
}
if(str[i][0] >= '0' && str[i][0] <= '9')
for(int j = (int)str[i].size() - 1; j >= 0; j--) cout << str[i][j];
else cout << str[i];
if(i != 0) cout << " ";
}
return 0;
}