栈
一、结构体定义
1.顺序栈
typedef struct
{
int data[maxSize];
int top;
}SqStack;
2.链栈*
typedef struct LNode
{
int data;
struct LNode *next;
}LNode;
二、操作
1.栈空
int isEmpty(SqStack st)
{
return st.top==-1?1:0;
}
2.进栈
int push(SqStack &st,int x)
{
if(st.top==maxSize-1)
return 0;
st.data[++st.top]=x;
return 1;
}
3.出栈
int pop(Sqstack &st,int &x)
{
if(st.top==-1)
return 0;
x=st.data[top--];
return 1;
}

浙公网安备 33010602011771号