题解 | #句子逆序#
句子逆序
https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
#include <iostream>
using namespace std;
int main() {
string str;
getline(cin, str);
for(int i = str.length() - 1; i >= 0; i --){
if(str[i] == ' '){
for(int j = i + 1; j < str.length(); j ++){
if(str[j] == ' ') break;
cout << str[j] ;
}
cout << str[i];
}
}
for(int i = 0; i < str.length(); i ++){
if(str[i] == ' ') break;
cout << str[i];
}
return 0;
}
// 64 位输出请用 printf("%lld")
查看2道真题和解析