标签:size bst off class tle ever 内容 desc des
class Solution { public: void fanzhuandanci(string &word, int start, int end) { int i = start; int j = end; while (i <= j) { swap(word[i], word[j]); ++i; --j; } } string ReverseSentence(string str) { str +=" "; fanzhuandanci(str,0,str.size()-1); str +=" "; int start = 0; int end = 0; while (start<str.size()) { while (str[start] == ‘ ‘&&start<str.size()) { ++start; } end = start; while (str[end] != ‘ ‘&&end<str.size()) { ++end; } --end; fanzhuandanci(str, start, end); ++end; start = end; } return str.substr(1,str.size()-2); } };
标签:size bst off class tle ever 内容 desc des
原文地址:http://www.cnblogs.com/159269lzm/p/7262256.html