class Solution {
public:
string reverseWords(string s) {
auto it1 = s.begin();
auto it2 = s.begin();
while(it2 != s.end()){ \先翻转每个单词
it2 = it1 + 1;
while((*it2) != ‘ ‘&&it2 != s.end()) it2++;
reverse(it1,it2);
it1 = it2 + 1;
}
reverse(s.begin(),s.end()); \最后从头到尾翻转
return s;
}
};