(1)初始化栈 SeqStack *InitSeqStack() SeqStacl *s; s=(SeqStack*)malloc(sizeof(SeqStack)); if(s) {s->top=-1; return s; else return NULL; }
(1)初始化栈 SeqStack *InitSeqStack( ) { SeqStacl *s; s=(SeqStack*)malloc(sizeof(SeqStack)); if(s) { s->top=-1; return s; } else return NULL; }
(2)判栈空 int EmptySeqStack(SeqStack *s) return(s->top==-1?1:0) } (3)判栈满 int FullSeqStack(SeqStack *s) return (s->top==MAXSIZE-1?1:0
(2)判栈空 int EmptySeqStack(SeqStack *s) { return (s->top= =-1? 1 : 0) } (3)判栈满 int FullSeqStack(SeqStack *s) { return (s->top= =MAXSIZE-1? 1 : 0) }
(4)入栈 int PushSeqStack(SeqStack *s,datatype x) { if (s->top==maxsize-1)return 0; else {s->top++; s->data[s->top]=x; return 1; }
(4)入栈 int PushSeqStack(SeqStack *s, datatype x) { if (s->top= =maxsize-1} return 0; else { s->top++; s->data[s->top]=x; return 1; } }
(5)出栈 int PopSeqStack(Seqstack *s ,datatype *x) { if(EmptySeqStack(s))return 0; else *x=s->data[s->top]; s->top--; return 1; } }
(5)出栈 int PopSeqStack(Seqstack *s ,datatype *x) { if(EmptySeqStack(s)) return 0; else { *x= s->data[s->top]; s->top--; return 1; } }
(6)取栈顶元素 datatype GetTopSeqStack(Seqstack *s,) if(EmptySeqStack(s)) return 0; else return(s->data[s->top]); }
(6)取栈顶元素 datatype GetTopSeqStack(Seqstack *s,) { if(EmptySeqStack(s)) return 0; else return(s->data[s->top]); }