1009. Irony (20)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.