栈的基本操作如下:
//栈的定义
#include <bits/stdc++.h>
#define MAXSIZE 100
typedef char SElemType;
typedef char Status;
typedef struct
{
SElemType *base;//栈底指针
SElemType *top;//栈顶指针
int stacksize;//栈的可用最大容量
} SqStack;
//初始化
Status InitStack(SqStack &S)
{
//构造一个空栈
S.base = new SElemType[MAXSIZE];
if(!S.base) exit(OVERFLOW);
S.top=S.base;
S.stacksize=MAXSIZE;
return 1;
}
//进栈出栈操作
Status Push(SqStack &S,SElemType e)
{
if(S.top-S.base==S.stacksize) return 0;
*S.top++=e;
return 1;
}
Status Pop(SqStack &S,SElemType e)
{
if(S.top-S.base==0) return 0;
e=*--S.top;
return 1;
}
//输出栈内元素
SElemType Put(SqStack &