Given an English sentence, you are asked to write a program that reverses the order of all the words in the sentence.
input Format: The test input contains a test case that gives a string with a total length of not more than 80 in a row. The string consists of several words and a number of spaces, where the word is a string of letters (case-sensitive), the words are separated by 1 spaces, and the input guarantees that there are no extra spaces at the end of the sentence.
output format: the output of each test case takes one line, and the output is reversed after the sentence.
Input Sample:
Hello World Here I Come
Sample output:
Come I here World Hello
Ideas: Iterates through a string, and when it encounters a character that is not a space, it is entered into another two-dimensional character array, and when it encounters a character that is a space, it is not entered.
#include <stdio.h>
#include <string.h>
int main ()
{
Char a[85],c[85][85];
Gets (a);
int I,j,l=strlen (a), x=0,y=0;
for (i=0;i<l;i++)
{
if (a[i]== ")
{
C[x][y]= ';//pay attention to the details: Add the string end flag so that the output
x + +; Go to another string
y=0;//go to the first character of the string
}
Else
{
C[x][y]=a[i];
y++;
}
}
for (i=x;i>=0;i--)
{
if (i!=0)
{
printf ("%s", C[i]);
}
Else
printf ("%s", C[i]);
}
return 0;
}
1009. Irony (20)