#include <iostream>
using namespace std;
#define STACKINITSIZE 20
#define INCREASEMENT 5
//树的结构体声明
typedef struct BiTNode {
char data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
//栈的结构体声明
typedef BiTree ElemType;
typedef struct{
ElemType *base;
int top;
int stacksize;
}SqStack;
SqStack S;
//The relevant operations of the stack
void InitStack(SqStack &S) {
//the initialization of the stack
S.base=(ElemType*)malloc(STACKINITSIZE*sizeof(ElemType));
if(!S.base) exit(0);
S.top=0; S.stacksize=STACKINITSIZE;
}
void Push(SqStack &S,ElemType e) {
//insert one element into the stack
if(S.top==S.stacksize)
S.base=(ElemType *)malloc((STACKINITSIZE+INCREASEMENT)*sizeof(ElemType));
S.base[S.top++]=e;
}
void Pop(SqStack &S,ElemType &e) {
//delete one element from the stack
if(S.top==0)
exit(0);
e=S.base[--S.top];
}
int GetTop(SqStack S,ElemType &e) {
//get the top element from the stack
if(S.top==0)
return 0;
e=S.base[S.top-1];
return 1;
}
int StackEmpty(SqStack S)
{
if(S.top==0)
return 1;
return 0;
}
//队列的结构体
#define MAXQSIZE 20