#include<iostream> using namespace std; void main() { char arr[1000]; int a,n; int s,t; cin>>a; getchar(); for(int i=0;i<a;i++) { gets(arr); n=strlen(arr); s=0; for(int j=0;j<=n;j++) { if(arr[j]==' '||arr[j]=='\0') { t=j; for(int l=t-1;l>=s;l--) { cout<<arr[l]; } s=t+1; if(s!=n+1) cout<<" "; } } cout<<endl; } }
Problem Description
Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
|
Input
The 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. |
Output
For each test case, you should output the text which is processed.
|
Sample Input
3 olleh !dlrow m'I morf .udh I ekil .mca |
Sample Output
hello world! I'm from hdu. I like acm. <div style="" border-bottom:="" #b7cbff="" 1px="" dashed;="" border-left:="" padding-bottom:="" 6px;="" padding-left:="" padding-right:="" font-family:="" times"=""> |
极简,专注,速度,极致