📄 sqstack.h
字号:
#include"sj.h" /*调用自定义库函数*/
typedef struct
{ ElemType elem[MAXSIZE];
int top;
}SeqStack; /*定义顺序栈结构*/
void InitStack_Sq(SeqStack *s) /*初始化栈操作*/
{s->top=-1;
}/*InitStack_sq*/
Status Empty_Sq(SeqStack *s) /*判栈是否为空*/
{return (s->top==-1);
}/*Empty_sq*/
Status Push_SeqStack(SeqStack *s, ElemType x)
{if (s->top==MAXSIZE-1) return OVERFLOW ; /* 栈满不能入栈 */
else { s->top++;
s->elem[s->top]=x ;
return OK;
}
}
Status Pop_SeqStack(SeqStack *s, ElemType *y)
{ if (Empty_Sq(s)) return OVERFLOW; /* 栈空不能出栈 */
else { *y=s->elem[s->top];
s->top--; return OK;
} /* 栈顶元素存入*y,返回 */
}
ElemType GetTop(SeqStack *s,ElemType *y) /*取顶元素*/
{if (Empty_Sq(s)) return OVERFLOW; /* 栈空不能出栈 */
else { *y=s->elem[s->top];
return OK;
}
}/*SQstack.h*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -