实现入栈和出栈(已有函数
函数已给出求实现完整C程序,(我是刚学到这的小白,请见谅#define maxsize
typdef struct{
ElementTpe Data[maxsize];
int top;
};
void push(stack *ptrs, ElemementType item){ //入栈
if (ptrs->top == maxsize - 1){
printf("栈满"); return;
}
else{
ptrs->Data[++(ptrs->top)] = item;
return;
}
}
ElementType pop(stack *ptrs){ //出栈
if (ptrs->top == -1){
printf("堆栈空");
return ERROR;
}
else
return(ptrs->Data[(ptrs->top)--]);
}