顺序栈的基本操作
#define Maxsize 50
typedef struct{
ElemType data[Maxsize];
int top;
}SqStack;
void InitStack(SqStack &s){
s.top=-1;
}
bool IsEmpty(SqStack s){
if(s.top==-1)
return true;
else
return false;
}
bool Push(SqStack &s,ElemType x){
if(s.top==Maxsize-1)
return false;
s.data[++s.top]=x;
return true;
}
bool Pop(SqStack &s,ElemType &x){
if(s.top==-1)
return false;
x=s.data[s.top--];
return true;
}
bool GetTop(SqStack s,ElemType &x){
if(s.top==-1)
return false;
x=s.data[s.top];
return true;
}