#include<bits/stdc++.h>
using namespace std;
struct stackk
{
char value;
stackk* nex;
};
void init(stackk *&s)
{
s = (stackk*)malloc(sizeof(stackk));
s->nex=NULL;
}
void push(int x,stackk *&s)
{
stackk *tmp;
tmp = (stackk*)malloc(sizeof(stackk));
tmp->nex = s->nex;
tmp->value=x;
s->nex=tmp;
return ;
}
void pop(stackk *s)
{
s->nex=s->nex->nex;
return ;
}
void destroy(stackk *&s)
{
stackk *tmp;
tmp=s->nex;
while(tmp!=NULL)
{
free(s);
s=tmp;
tmp=s->nex;
}
free(s);
return ;
}
void display(stackk *s)
{
cout<<s->nex->value<<endl;
}
int main()
{
int n;
cin>>n;
stackk *st;
init(st);
for(int i=1;i<=n;++i)
{
char b;
char oper;
cin>>oper;
if(oper=='1')
pop(st);
else
{
cin>>b;
push(b,st);
}
display(st);
}
destroy(st);
return 0;
}
网友评论