1、二指针做法
class Solution {
public:
string reversePrefix(string word, char ch) {
int i,j=0;
char tmp;
for(i=0;word[i];++i)
if(word[i]==ch) break;
if(word[i]=='\0') return word;
else
{
while(j<i)
{
tmp=word[j],word[j]=word[i],word[i]=tmp;
++j;
--i;
}
return word;
}
}
};