# include <iostream>
# include <math.h>
# define Maxsize 100
typedef int Elemtype;
typedef struct {
Elemtype data[Maxsize];
int top;
} Stack;
typedef struct Linknode{
Elemtype data;
struct Linknode *next;
} *LiStack;
void InitStack(Stack &S){
S.top = -1;
}
bool StackEmpty(Stack &S){
if(S.top==-1)
return false;
else
return true;
}
bool Push(Stack &S,Elemtype x){
if(S.top == Maxsize-1)
return false;
S.data[++S.top] = x;
return true;
}
bool Pop(Stack &S,Elemtype &x){
if(S.top==-1)
return false;
x = S.data[S.top--];
return true;
}
bool GetTop(Stack &S,Elemtype &x){
if(S.top==-1)
return false;
x = S.data[S.top];
return true;
}