思路:
创建string类型的容器,然后输入,调用泛型算法里的逆序,然后输出
代码:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
vector<string> svec;
string S;
while (cin >> S) {
svec.push_back(S);
}
reverse(svec.begin(),svec.end());
for (int i = 0; i < svec.size()-1; i++) {
cout << svec[i]<<" ";
}
cout << svec[svec.size() - 1];
}