#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
typedef struct zhan{
int *base;
int *top;
int stacksize;
}SqStact;
void InitStack(SqStact &S){
S.base = new int[MAXSIZE];
if (!S.base){
printf("ERROR");
exit(0);
}
S.top = S.base;
S.stacksize = MAXSIZE;
printf("OK\n");
}
void Push(SqStact &S, int e){
if (S.top - S.base == S.stacksize){
printf("ERROR");
exit(0);
}
*S.top ++ = e;
printf("OK\n");
}
void Pop(SqStact &S, int &e){
if (S.top == S.base){
printf("Error");
exit(0);
}
e = *--S.top;
}
int main(){
SqStact S;
int a = 0;
InitStack(S);
Push(S, 5);
Push(S, 5);
Pop(S, a);
printf("a = %d", a);
}