正在加载图片...
/*压栈,将数据元素x压入指针s所指的栈* int push (sqstktp s, elemtype x) i if (s->top= =N-1) return(False) /*如果栈满,返回 False* s-> stack[++s->top]=x;/米栈不满,x入栈。*/ return(True) /*弹栈,将栈顶元素出栈*/ elemtype pop (sgstk i elemtype x x arrtime=Null return(x);/如果栈空,返回空值*/ return(s-> stack[s->top+1]);/*返回栈顶元素*/ /*初始化队列*/ void inilinkedque (linkedquetp s) s->fornt=(queueptr )malloc (sizeof (queueptr));/pHE 一个新节点,作头节点*/ s->rear= s->fornt s->front->next =Null s- front->num=0;/*头节点的num保存队列元素的个数* 1/* nilinkedque * /*数据入队列*/ void enl ue(linkedquetp s, int numl) p=( queueptr) malloc( sizeof( queueptr));/*产生一个新节{ s->top= -1; } /*压栈,将数据元素 x 压入指针 s 所指的栈*/ int push(sqstktp s, elemtype x) { if (s->top= =N-1) return (False); /*如果栈满,返回 False*/ else { s->stack[++s->top]=x; /*栈不满,x 入栈。*/ return (True); } }/*push*/ /*弹栈,将栈顶元素出栈*/ elemtype pop (sqstktp *s) { elemtype x ; if (s->top<0) { x.num=Null; x.arrtime=Null; return (x); /*如果栈空,返回空值*/ } else { s->top - -; return (s->stack[s->top+1]); /*返回栈顶元素*/ } }/*pop*/ /*初始化队列*/ void inilinkedque (linkedquetp s) { s->fornt= (queueptr )malloc (sizeof (queueptr)); /产生 一个新节点,作头节点*/ s->rear= s->fornt; s->front->next =Null; s->front->num =0; /*头节点的 num 保存队列元素的个数*/ }/* nilinkedque */ /*数据入队列*/ void enlinkedque (linkedquetp s, int numl) { queueptr *p; p= (queueptr)malloc (sizeof (queueptr));/*产生一个新节 点*/ p->num =numl;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有