#include <iostream>
using namespace std;
#define MaxSize 10
typedef struct{
int data[MaxSize];
int top;
}SqStack;
void InitSqStack(SqStack &S);
bool IsEmpty(SqStack S);
bool Push(SqStack &S,int x);
bool Pop(SqStack&S,int &x);
bool GetTop(SqStack S,int &x);
int Length(SqStack S);
int main()
{
SqStack S;
InitSqStack(S);
for(int i=0;i<5;i++)
{
Push(S,i);
}
cout<<"____"<<endl;
cout<<Length(S)<<endl;
int ans=0;
GetTop(S,ans);
cout<<ans<<endl;
cout<<IsEmpty(S);
}
void InitSqStack(SqStack &S)
{
S.top=-1;
}
bool IsEmpty(SqStack S)
{
return(S.top==-1);
}
bool Push(SqStack &S,int x)
{
if(S.top==MaxSize-1)
return false;
S.data[++S.top]=x;
return true;
}
bool Pop(SqStack&S,int &x)
{
if(S.top==-1)return false;
x=S.data[S.top--];
return true;
}
bool GetTop(SqStack S,int &x)
{
if(S.top==-1)return false;
x=S.data[S.top];return true;
}
int Length(SqStack S)
{
return (S.top+1);
}