#include <stdio.h>
#include <string.h>
#define MAX_SIZE 1024
void reverse_word(char ch[])
{
int count = 0,i,flag = 0;
char *p = ch;
char a[10][10];
while(*p != '\0')
{
flag = 0;
while((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z'))
{
if(flag==0)
{
i=0;
}
flag = 1;
a[count][i++] = *p;
p++;
}
a[count][i++]=' ';
a[count][i]='\0';
p++;
if(flag == 1)
{
count++;
flag = 0;
}
}
ch[0]='\0';
for(i = count-1;i>=0;i--)
{
strcat(ch,a[i]);
}
}
int main()
{
char ch[MAX_SIZE];
printf("Please input a string:\n");
gets(ch);
reverse_word(ch);
printf("\nthe result is:\n%s\n",ch);
return 0;
}