解题思路:先到ch在word中的位置,然后对在此之前的字符进行换位。
char * reversePrefix(char * word, char ch){
int i;
for(i=0;word[i]!=ch;i++)
{
if(word[i]=='\0')
{
return word;
}
}
char t;
int k=i;
for(int j=0;j<k/2+1;j++)
{
t=word[j];
word[j]=word[i];
word[i]=t;
i--;
}
return word;
}