注意:除了空格符号,可能用其他非字母的任意符号分割单词
只需从字母开始计算,然后逆序输出。不知道为什么,感觉这道题它,不困难
//注意:可能用其他字符代表空格
#include<stdio.h>
#include<string.h>
int main(void){
char str[100][21],temp[1001];
int n = 0,len=0,i,j=0;
memset(str,0,sizeof(str));
while(fgets(temp, sizeof(temp), stdin)){
len=strlen(temp);
for(i=0;i<len;i++){
if((temp[i] >= 'a' && temp[i]<= 'z') || (temp[i] >= 'A' && temp[i]<= 'Z' )){
str[n][j] = temp[i];
j++;
}else if(j > 0){
j=0;
n++;
}
}
}
for(i = n-1;i>0;i--){
printf("%s ",str[i]);
}
printf("%s\n",str[0]);
return 0;
}
京公网安备 11010502036488号