题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
getline(cin, str);
vector<string> vec;
string word = "";
for(int i=0; i<str.size(); i++){
if(isalpha(str[i])){
word += str[i];
}
else{
vec.push_back(word);
word = "";
}
}
vec.push_back(word);
reverse(vec.begin(), vec.end());
for(auto i:vec) cout << i <<" ";
cout << endl;
return 0;
}
// 64 位输出请用 printf("%lld")

查看11道真题和解析