Invert Words
Time limit: 1 Sec memory limit: MB
Submissions: 22 Resolution: 6
The status of your title: Completed
Submitted State [Discussion Version] Title Description
Restores each inverted word in the input. input
The input contains samples of several sets of test specimens. The first behavior is an integer t, which represents the number of test samples followed by a T test sample.
Each test sample occupies one line and contains multiple words. A line has a maximum of 1000 characters. Output
For each test sample, you should output the converted text. Sample Input
2
I Evol!ANIHC
Olleh!dlrow Sample Output
I love china!
Hello world!
#include <stdio.h> #include <string.h> int main () {int t;
scanf ("%d", &t); GetChar ();
Absorbs newline characters while (t--) {char c[1000];
Gets (c);
for (int i=0;i<=strlen (c); i++) {if (c[i]== ' | | c[i]== ')//Meet space or terminator, reverse output Word {
int j=i-1; while (J!=-1 && c[j]!= ")//here is && instead of | |
, meet the space or subscript as-1, a word output end {printf ("%c", C[j]);
j--;
} if (I==strlen (c))//All words have been output, newline printf ("\ n");
else printf ("");
}}} return 0; }