#include<bits/stdc++.h>
using namespace std;
const int StackSize=10;
typedef struct
{
int data[StackSize];
int top;
}SeqStack; //定义顺序栈
void InitStack(SeqStack *S)
{
S->top=-1;
} //置栈空
int StackEmpty(SeqStack *S)
{
return S->top==-1;
} //判栈空
int StackFull(SeqStack *S)
{
return S->top==StackSize-1;
} //判栈满
int Push(SeqStack *S,int x)
{
if(StackFull(S))
{
puts("Error:full");
return false;
}
S->data[++S->top]=x;
return true;
} //进栈
int Pop(SeqStack *S,int x)
{
if(StackEmpty(S))
{
puts("Error:empty");
return false;
}
x=S->data[S->top-1];
cout<<x<<" ";
S->top--;
return 1;
} //退栈
int StackTop(SeqStack *S,int x)
{
if(StackEmpty(S))
{
puts("Error:empty");
return false;
}
x=S->data[S->top];
return true;
} //取栈顶
int main()
{
SeqStack *S;
int x;
InitStack(S);
for(int i=1;i<=10;i++)
{
cin>>x;
Push(S,x);
}
int t=S->data[S->top];
StackTop(S,t);
cout<<t<<" ";
for(int i=1;i<10;i++)
Pop(S,t);
return 0;
}
//Sequence Stack