有那个插件可以点播看CCAV的节目?# PDA - 掌中宝
g*r
1 楼
大牛来指点一下代码有没有改进的地方?
方法的就是从string tail开始一个一个的读
string reverseWord(string s)
{
string result;
int i=s.size()-1; //start from the last character
while(i>=0){
while(i>=0 && isspace(s[i])) i--; //advance i to a non-space letter
int j=i-1;
while(j>=0 && !isspace(s[j])) j--; //find the previous space
result += s.substr(j+1, i-j);
if(j>=0) result += " ";
i = j-1;
}
return result;
}
方法的就是从string tail开始一个一个的读
string reverseWord(string s)
{
string result;
int i=s.size()-1; //start from the last character
while(i>=0){
while(i>=0 && isspace(s[i])) i--; //advance i to a non-space letter
int j=i-1;
while(j>=0 && !isspace(s[j])) j--; //find the previous space
result += s.substr(j+1, i-j);
if(j>=0) result += " ";
i = j-1;
}
return result;
}