2022
05-15
05-15
C语言中栈的两种实现方法详解
目录一、顺序栈二、链式栈总结一、顺序栈#include<stdio.h>#include<stdlib.h>#definemaxsize64//定义栈typedefstruct{intdata[maxsize];inttop;}sqstack,*sqslink;//设置栈空voidClearstack(sqslinks){s->top=-1;}//判断栈空intEmptystack(sqslinks){if(s->top<0)return1;elsereturn0;}//进栈intPush(sqslinks,intx){if(s->top>=maxsize-1)return0;else{s->top++;s->data[s->top]=x;return...
继续阅读 >