例如:
输入:i came from china.
输出:china. from came i
while (j>i)
{
temp=str[j];
str[j]=str[i];
str[i]=temp;
j--;
i++;
}
cout<<str<<endl;//字符串逆转了
i=0;
while(str[i]!='\0')
{
if(str[i]!=' ')
{
begin=i;//begin 是第一个单词开始的地方
while (str[i]&&str[i]!=' ')
i++;
i--;
end=i;//end是第一个单词结束的地方
}
while(end>begin)
{
temp=str[begin];
str[begin]=str[end];
str[end]=temp;
end--;
begin++;
}
i++;
}