Text ReverseTime
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 17702 Accepted Submission (s): 6717
Problem Descriptionignatius likes to the 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.
Inputthe 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.
Outputfor Each test case, you should the output of 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. Hint Remember to use GetChar () to read ' \ n ' after the Interger T, then the If use gets () to read a line and process it.
Authorignatius.l
#include <stdio.h> #include <string.h>char s[1002];int main () {int test,i,j,len,k;scanf ("%d", &test); GetChar (), while (test--) {gets (s), Len=strlen (s), for (i=0,k=0;i<len;i++) {if (s[i]== ") {for (j=i-1;j>=k; j--) { printf ("%c", S[j]); } printf (""); k=i+1;} } for (j=len-1;j>=k;j--) printf ("%c", S[j]);p rintf ("\ n");} return 0;}
Text Reverse (Hangzhou electric oj1062)