提交时间:2019-12-28 20:34:08

运行 ID: 4048

#include<iostream> using namespace std; int main() { int n; char str[1001]; 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; }