#include<stdio.h>
#include<string.h>
#include<assert.h>
void reverse(char*left,char*right)
{
while(left<right)
{
char tmp = 0;
tmp = *left;
*left = *right;
*right = tmp;
left++;
right--;
}
}
int main()
{
char arr[100] = {0};
int len = strlen(arr);
char *start = arr;
reverse(arr,arr+len-1);
gets(arr);
while(*start)
{
char*end = start;
while(*end !=' '&& *end !='\0')
{
end++;
}
reverse(start,end-1);
if(*end == ' ')
start = end+1;
else
start = end;
}
printf("%s\n",arr);
return 0;
}
标签:beijing,arr,right,end,like,char,start,倒置,left From: https://blog.51cto.com/u_13668714/5940185