巧妙的利用了输入以空格隔开的设定,于是字符串数组存一下倒序输出就完事了
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<string>s;
string t;
while(cin>>t)s.push_back(t);
for(int i=s.size()-1;i>=0;i--){
cout<<s[i]<<' ';
}return 0;
}

京公网安备 11010502036488号