#include "seqstack.h"
int initSeqStack(SeqStack* S){
S->top = 0;
return 0;
}
int clearSeqStack(SeqStack* S){
for (int i=0; i< S->top; i++)
S->data[i] = 0;
S->top = 0;
return 0;
}
int isEmptySeqStack(SeqStack S){
return S.top > 0 ? 1 : 0;
}
int getTop(SeqStack S){
return S.data[S.top-1];
}
int PushSeqStack(SeqStack* S, int value){
if(S->top == STACKMAXSIZE)
return 1;
S->data[S->top]= value;
S->top++;
return 0;
}
int PopSeqStack(SeqStack* S){
if(S->top == 0)
return 1;
return S->data[S->top-- - 1];
}
int lengthSeqStack(SeqStack S){
return S.top;
}
(二)顺序栈函数定义
最新推荐文章于 2022-11-11 17:52:09 发布