.栈(顺序)头文件
#define MAXSIZE 100
typedef int datatype;
typedef struct{
datatype a[MAXSIZE];
int top;
}sequence_stack;
2.栈(顺序)的初始化
void init (sequence_stack *st){
st->top=0;
3.判断栈(顺序)是否为空
int empty(squence_stack st){
return(st.top?0:1);
4.读栈顶的(顺序)节点值
datatype read(squence_stack st){
if(empty(st)){
printf("栈顶为空"); exit(1);
}
else
return st.a[st.top-1];
}
5.栈(顺序)插入(进栈)
void push(sequence_stack *st,datatype x){
if(st->top==MAXSIZE){
printf("the sequence stack is full"); exit(1);
}
st->a[st->top]=x;
st->top++;
}
6.栈(顺序)删除(出栈)