#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main(){
char a[1010];
int n;
cin >> n;
cin.get(); //空格还是得吸的
while(n --){
gets(a);
int length = strlen(a); //获取字符串长度
int k = -1;
for(int i = 0; i <= length; i ++){
if(a[i] == ‘ ‘ || i == length){
for(int j = i - 1; j != k && j >= 0; j --){
putchar(a[j]);
}
k = i;
if(i != length)
putchar(‘ ‘);
}
}
cout << endl;
}
return 0;
}
原文地址:https://www.cnblogs.com/Elvis827/p/8626438.html