typedef int SElemType;
typedef struct LNode
{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
bool InitStack(SqStack &S)
{
S.base = new SElemType[MAXSIZE];
if(!S.base) return ERROR;
S.top = S.base;
S.stacksize = MAXSIZE;
return OK;
}
bool Push(SqStack &S,SElemType e)
{
if(S.top - S.base == S.stacksize) return ERROR;
*(S.top++) = e;
return OK;
}
bool Pop(SqStack &S,SElemType &e)
{
if(S.top==S.base) return ERROR;
e = *(--S.top);
return OK;
}
SElemType GetTop(SqStack S)
{
if(S.top!=S.base)
return *(S.top - 1);
return ERROR;
}