ZSC_ Winter Training 7

Source: Internet
Author: User


Ignatius likes to 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.


The 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.


For each test case, the should output of the text which is processed.

Sample Input

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

Sample Output

1#include <iostream>2#include <cstring>3#include <cstdio>4#include <algorithm>5 using namespacestd;6 intMain ()7 {8     Chara[1400];9     intN;Tenscanf"%d",&n); One GetChar (); A      while(n--) -     { - gets (a); the         intlen=strlen (a); -         intnext[ the],m=0; -          for(intI=0; i<=len;i++) -         { +             if(a[i]==' '|| i==len) -             { +                  for(intj=i-1; j>=0&&a[j]!=' '; j--) A                 { atnext[m++]=J; -                 } -             } -             if(a[i]==' ') -             { -next[m++]=i; in             } -         } to          for(intI=0; i<len;i++) +         { - Putchar (A[next[i]); the         } *printf"\ n"); $     }Panax Notoginseng}
View Code

Hello world! I ' m from Hdu. I like ACM.


Remember to use GetChar () to read ' \ n ' after the Interger T, then the If use gets () to read a line and process it.          

ZSC_ Winter Training 7

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.