#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class Solution {
public:
string reverseWords(string s) {
stringstream ss;
string ans = "", temp;
ss << s;
while (ss >> temp) {
ans = " " + temp + ans;
}
if (ans != "")
ans.erase(ans.begin());
return ans;
}
};
int main() {
Solution A;
cout << A.reverseWords(" asd wqeqwe wqeeqeq ") << endl;;
cin.get();
return 0;
}
https://jingyan.baidu.com/article/d3b74d643657d61f77e6092e.html
很好用记录一下