提交时间:2019-12-27 19:23:12
运行 ID: 3908
#include<iostream> 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; } return 0; }