Given a word of English, asking you to write a program, all the words of the sentence order reversed output.
Input formats:
Test input comprises a test case, given the string length does not exceed a total of 80 in a row. String composed of several words and a number of spaces, where the word is English letters (case is case) consisting of string, separated by a space between words, the input end of the sentence to ensure that no extra space.
Output formats:
Each test case output per line, output sentence after the reverse.
Sample input:
Hello World Here I Come
Sample output:
Come I Here World Hello
#include <stdio.h>
#include <string.h>
int main()
{
char _str[90],str[90][90];
gets(_str); //输入一个字符串,gets()识别换行符作为结束
int k=0,j=0;
for(int i=0; i<strlen(_str); i++)
{
if(_str[i]!=' ') //找到一个字符串
{
str[j][k++]=_str[i]; //用j记录二维数组的第一维,k记录二维数组的第二维
}
else
{
k=0; //一维加1,二维归0
j++;
}
}
for(int i=j; i>0; i--) //逆序输出二维数组
printf("%s ",str[i]);
printf("%s\n",str[0]);
return 0;
}
operation result: