#include <iostream>
using namespace std;
#define MaxSize 20
#define Error 0
#define Ok 1
typedef int Elemtype;
typedef int Status;
struct SqStack{
Elemtype data[MaxSize];
int top;
};
Status InitStack(SqStack* s){
s->top=-1;
return Ok;
}
Status Clear(SqStack* s){
s->top=-1;
return Ok;
}
bool IsEmpty(SqStack s){
if(s.top==-1) return true;
else return false;
}
int Length(SqStack s){
return s.top+1;
}
Status GetTop(SqStack s,Elemtype* e){
if(s.top==-1) return Error;
*e=s.data[s.top];
}
Status Push(SqStack* s,Elemtype e){
if(s->top==MaxSize-1) return Error;
++s->top;
s->data[s->top]=e;
return Ok;
}
Status Pop(SqStack* s,Elemtype* e){
if(s->top<0) return Error;
*e=s->data[s->top];
--s->top;
return Ok;
}
Status Traverse(SqStack s){
for(int i=0;i<=s.top;++i)
cout<<s.data[i]<<' ';
cout<<endl;
return Ok;
}
int main(){
SqStack s;
InitStack(&s);
cout<<Length(s)<<IsEmpty(s)<<endl;
Elemtype ein=77;
Elemtype eout;
Push(&s,ein);Push(&s,ein);
Traverse(s);
cout<<Length(s)<<IsEmpty(s)<<endl;
GetTop(s,&eout);
cout<<eout<<Length(s);
Pop(&s,&eout);
cout<<eout<<Length(s);
}