#define MAXSIZE 1000
struct stack
{
int data[MAXSIZE]; //存储数据的数组
int top; //栈顶
}
bool empty(stack &s){
return s.top==0; //判断栈是否为空
}
bool full(stack &s){
return s.top==MAXSIZE; //判断栈是否为满
}
bool push(stack &s,int da){ //入栈操作
if(full(s))
return false;
s.data[s.top++]=da;
return true;
}
bool pop(stack &s){ //出栈操作
if(empty(s))
return false;
s.top--;
return true;
}
bool gettop(stack &s,int da){ //取栈顶元素
if(empty(s))
return false;
da=s.data[s.top-1];
return true;
}