[CODE]int push(sqstack *s,elemtype e) //进栈
{
if(s->top-s->base>=s->stacksize)//栈满,追加存储空间
{
s->base=(elemtype *)realloc(s->base,(stack_init_size+stackincrement)
*sizeof(elemtype));
if(s->base==NULL)
{
printf("栈满,追加分配失败!\n");
exit(1);
}
s->top=s->base+s->stacksize;
s->stacksize+=stackincrement;
}
*(s->top++)=e;
return 1;
}
int pop(sqstack *s,elemtype *e) //出栈
{
if(s->top==s->base)
{
printf("栈空,不能出栈操作!\n");
return 0;
}
*e=*(--s->top);
return 1;
}[/CODE]
顺序实现