解题思路:
注意事项:
参考代码:
#include <stdio.h>
#include <string.h>
int main()
{
char str[501];
gets(str);
str[strlen(str)] = '\0';
int i = 0, start = 0, end = 0, j;
while (1)
{
while (str[i] != ' ' && str[i] != '\0')
{
i++;
}
end = i - 1;
for (j = start; j <= (start+end)/2; j++)
{
char c;
c = str[j];
str[j] = str[end - (j - start)];
str[end - (j - start)] = c;
}
if (str[i] == '\0')
break;
start = i + 1;
i++;
}
printf("%s\n", str);
return 0;
}
0.0分
0 人评分