Description
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.
Input
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.
Output
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.
Hint
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