Problem descriptionignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you showould 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.
// This question is not difficult. The key is to find spaces.
# Include <stdio. h> # include <string. h> int main () {int N, I, j, Len, a, B; char STR [1000], s [1000] [1000], T; scanf ("% d", & N); getchar (); While (n --) {gets (STR); memset (S, '\ 0 ', sizeof (s); a = B = 0; Len = strlen (STR); for (I = 0; I <Len; I ++) {If (STR [I] = '') {A ++; B = 0; continue;} s [a] [B] = STR [I]; // use the S array to store the string B ++ for each space partition.} for (I = 0; I <= A; I ++) {Len = strlen (s [I]); For (j = 0; j <Len/2; j ++) // reverse string {T = s [I] [J]; s [I] [J] = s [I] [len-j-1]; s [I] [len-j-1] = T;} printf ("% s ", s [I]); if (I! = A) // output space putchar ('');} printf (" \ n ");} return 0 ;}