#include<iostream>
using namespace std;
void revstr(char *str)
{
char *start,*end,*ptr;
start=end=ptr=str;
while(*ptr++!='/0')
{
if(*ptr==' ' || *ptr=='/0')
{
end=ptr-1;
while(start<end)
swap(*start++,*end--);
start=end=ptr+1;
}
}
start=str;
end=ptr-2;
while(start<end)
swap(*start++,*end--);
}
int main(){char str[]="i am from china";revstr(str);cout<<str<<endl;return 0;}
原文链接:https://www.f2er.com/javaschema/287712.html