第4章栈和队列4
3栈和队列算法实现的C语言源程序4
1栈的顺序存储结构及实现#include"stdio
h"#include"stdlib
h"#defineMAXSIZE100typedefintElemType;typedefstruct{ElemTypeelem[MAXSIZE];inttop;}SqStack;/*顺序栈的类型标识符*/第4章栈和队列voidOutStack(SqStackp);/*此处参数必须与下边函数说明一致*/voidInitStack(SqStack*p);voidPush(SqStack*p,ElemTypex);ElemTypePop(SqStack*p);ElemTypeGetTop(SqStackp);第4章栈和队列main(){SqStackq;inti,y,cord;ElemTypea;do{printf("\n");printf("\n主菜单\n");printf("\n1初始化顺序栈\n");printf("\n2插入一个元素\n");printf("\n3删除栈顶元素\n");printf("\n4取栈顶元素\n");printf("\n5结束程序运行\n");printf("\n---------------------------\n");printf("请输入您的选择(1,2,3,4,5)");scanf("%d",&cord);switch(cord)第4章栈和队列{case1:{InitStack(&q);OutStack(q);}break;case2:{printf("\n请输入插入的数据a=");scanf("%d",&a);Push(&q,a);OutStack(q);}break;case3:{a=Pop(&q);printf("\na=%d",a);OutStack(q);}break;case