Text reverse
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 16342 accepted submission (s): 6205
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.
# Include <stdio. h> # include <string. h> char a [1010], CH [1000]; int main () {int T, I, j; scanf ("% d", & T); getchar (); while (t --) {gets (a); I = 0; while (A [I]) {J = 0; while (A [I]! = ''& A [I]! = '\ 0') {ch [J] = A [I]; j ++; I ++;} ch [J] =' \ 0 '; strrev (CH); <span style = "white-space: pre"> </span> // pay attention to the use of this function, is to output the string in reverse order printf ("% s", CH); if (a [I] = '') {printf (" "); I ++ ;}} printf ("\ n");} return 0 ;}