提交时间:2019-12-29 10:10:27

运行 ID: 4143

#include<bits/stdc++.h> using namespace std; int main(){ int n; char str[1001]; scanf("%d%*c",&n); for(int k=1;k<=n;k++){ gets(str); int i=0; while(str[i]){ while(str[i]==' ')printf("%c",str[i++]); int WordLeft=i; while(str[i]&&str[i]!=' ')i++; int WordRight=i-1; while(WordLeft<=WordRight)printf("%c",str[WordRight--]); } cout<<endl; } }