class Solution {
public:
string reverseWords(string s) {
if(s.size()==0) return "";
reverse(s.begin(),s.end());
for (int i = 0; i < s.size();)
{
int j=i;
while(j<s.size()&&s[j]!=' ') j++;
reverse(s.begin()+i,s.begin()+j);
i=j+1;
}
return s;
}
};
标签:顺序,string,int,单词,翻转,size
From: https://www.cnblogs.com/tangxibomb/p/17390830.html