Text Reverse (Hangzhou electric oj1062)

Source: Internet
Author: User

Text ReverseTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 17702 Accepted Submission (s): 6717


Problem Descriptionignatius likes to the write words in reverse. Given a single line of text which are written by Ignatius, you should reverse all the words and then output them.

Inputthe input contains several test cases. The first line of the input was a single integer T which is the number of test cases. T test Cases follow.
Each test case contains a, with several words. There'll is at the most of characters in a line.

Outputfor Each test case, you should the output of the text which is processed.

Sample Input
3olleh!dlrowm ' I Morf. Udhi Ekil. MCA

Sample Output
Hello world! I ' m from Hdu. I like ACM. Hint Remember to use GetChar () to read ' \ n ' after the Interger T, then the If use gets () to read a line and process it.

Authorignatius.l
#include <stdio.h> #include <string.h>char s[1002];int main () {int test,i,j,len,k;scanf ("%d", &test); GetChar (), while (test--) {gets (s), Len=strlen (s), for (i=0,k=0;i<len;i++) {if (s[i]== ") {for   (j=i-1;j>=k; j--)   {      printf ("%c", S[j]);   }   printf ("");                k=i+1;}    } for (j=len-1;j>=k;j--)    printf ("%c", S[j]);p rintf ("\ n");} return 0;}

Text Reverse (Hangzhou electric oj1062)

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.