Give a test data: AB bcba CB note output space http://acm.hdu.edu.cn/showproblem.php? PID = 1062 problem descriptionignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you shocould reverse all the words and then output them.
Inputthe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. t test cases follow.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Outputfor each test case, you should output 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.HintRemember to use getchar () to read '\ n' After the interger T, then you may use gets () to read a line and process it.# Include <iostream>Using namespaceSTD;# Include <string. h>Int main () {intN,I,L,K,J; CharA,B[1000];CIN>N;Getchar(); // Read a carriage return while (N--){Gets(B);L=Strlen(B);K=0; (I=0;I<L;I++) {If (B[I] =32) \ If it is a space, it will be output, and Mark K to the next {Cout<"";K=I+1;} Else if (B[I+1] =32|B[I+1] ='\ 0') \ This is an error at the beginning, and you need to determine whether the last one is over {(J=I;J> =K;J--)Cout<B[J];K=I+1;}}Cout<Endl;}