提交时间:2019-12-31 21:08:35

运行 ID: 4192

#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; }