/*
思路:
利用 reverse 对字符串进行翻转
1. 获得输入的字符串
2. 调用reverse 整体翻转字符串
3. 加控制逻辑, 识别空格,翻转 翻转后的字符串
控制逻辑这块要多练一练
4. 打印输出
*/
#include <algorithm>
#include<iostream>
using namespace std;
int main(){
string str;
getline(cin, str);
reverse(str.begin(), str.end());
int len = str.length();
for(int i = 0; i < len; ++i){
int j = i;
while(str[j] != ' ' && j < len){
++j;
}
reverse( str.begin() + i, str.begin() + j);
i = j;
}
cout << str << endl;
}

京公网安备 11010502036488号