#include<stdio.h>#include<stdlib.h>#defineMAXSIZE50typedefstruct{int data[MAXSIZE];int top;//栈顶指针}SqStack;//初始化//判空//进栈//出栈//读栈顶元素//销毁栈intmain(){
SqStack S;//申明一个顺序栈(分配空间)InitStack(S);//初始化//判空if(StackEmpty(S)){printf("S现在是个空栈\n");}//入栈if(Push(S,2)){printf("2入栈成功!\n");}if(Push(S,3)){printf("3入栈成功!\n");}//取栈顶int top;//定义变量获取栈顶数字if(GetTop(S,top)){printf("Now,The top of this stack is:%d\n", top);}//出栈int t;if(Pop(S,t)){printf("%d出栈\n",t);}if(Pop(S, t)){printf("%d出栈\n", t);}//判空if(StackEmpty(S)){printf("S现在是个空栈\n");}//销毁栈if(DestroyStack(S)){printf("S栈已被销毁\n");}return0;}