题目链接
思路
用了栈,先进后出
代码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn=1e5;
int main()
{
stack<string> str;
string s;
while(cin>>s)
{
str.push(s);
}
cout<<str.top();
str.pop();
while(!str.empty())
{
cout<<" "<<str.top();
str.pop();
}
cout<<endl;
return 0;
}