这道题十分简单,直接用栈模拟即可。
code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
stack<string> s;
int main(){
int n;
cin>>n;
while(n--){
string op;
cin>>op;
if(op!="READ") s.push(op);
else cout<<s.top()<<"\n",s.pop();
}
return 0;
}