从每个单词开始到遇到空格或回车换行,依次倒序输出,其中还包括符号
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void shuchu(char *s,int *i)//当不是空格是倒序输出
{
char temp[100];
int j=0;
while((*s)!=32&&(*s)!='\0')
{
temp[j++]=*s++;
(*i)++;
}
j--;
for(;j>=0;j--)
printf("%c",temp[j]);
}
int main()
{
int i;
char str[10000];
while(gets(str))
{
for(i=0;str[i]!='\0';i++)
{
if(str[i]!=32)
{
shuchu(&str[i],&i);
i--;//在自定义函数中自加了一,考虑到循环中的自加一,这里要减一
}
else printf("%c",str[i]);//遇到空格直接输出
}
printf("\n");
}
system("pause");
return 0;
}