来源:互联网 发布:淘宝买东西怎么收货 编辑:程序博客网 时间:2024/06/07 09:59
//栈的顺序存储类型描述#define MaxSize 50typedef struct{ElemType data[MaxSize];int top;}SqStack;//初始化void InitStack(&S){S.top=-1;}//判断栈空bool StackEmpty(S){if(S.top==1)return true;elsereturn false;} //进栈bool Push(SqStack &S,ElemType x){if(S.top==MaxSize-1)return false;S.data[++S.top]=x;return true;} //出栈bool Pop(Sqstack &S,ElemType &x){if(S.top==-1)return false;x=S.data[S.top--];return true;} //读栈顶元素bool GetTop(SqStack S,ElemType *x){if(S.top==-1)return false;x=S.data[S.top];return true;}//栈的链式存储类型描述typedef struct LinkNode{ElemType data;struct LinkNode *next;}LiStack; 

原创粉丝点击