版权声明:本文为本人原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37316917/article/details/87890670
题目
代码
class Solution {
public:
string reverseWords(string s) {
for(int i=0,j=0;j<=s.size();j++)
{
if(j==s.size()||s[j]==' ')
{
reverse(s.begin()+i,s.begin()+j);
i=j+1;
}
}
return s;
}
};