代码
#include<stdio.h>
#include<string.h>
int main(int argc, char const *argv[])
{
char str1[20] = {0};
char str2[20] = {0};
char str3[20] = {0};
char *p2 = str2;
char *p3 = str3;
int i = 0, len = 0,count =0,j=0;
gets(str1);
len = strlen(str1);
char *p1 = str1+len-1;
for ( i = 0; i <=len; i++)
{
*p2++ = *p1--;
}
p2 = str2;
for ( i = 0; i <= len+1; i++)
{
if (*p2 == ' ' || *p2 == '\0')
{
for ( j = 1; j <=count; j++)
{
*p3++ = *(p2-j);
}
*p3++ = ' ';
count=0;
}
else if(*p2 != ' ')
{
count++;
}
p2++;
}
puts(str2);
puts(str3);
return 0;
}