//共享栈的结构体定义
typedef struct{
int elem[maxsize];
int top[2];//top[0]为s0栈顶 top[1]为s1栈顶
}SqStack;
//入栈
int push(SqStack &st,int stNo,int x)
{
if(st.top[0]+1<st.top[1])
{
if(stNo==0)
{
++(st.top[0]);
st.elem[s1.top[0]]=x;
return 1;
}
else if(stNo==1)
{
--(st.top[1]);
st.elem[s1.top[1]]=x;
return 1;
}
else
return -1;
}
}
//出栈
int pop(SqStack &st,int stNo,int &x)
{
if(stNo==0)
{
if(st.top[0]!=-1)
{
x=st.elem[st.top[0]];
--(st.top[0]);
return 1;
}
else
return 0;
}
if(stNo==-1)
{
if(st.top[1]!=maxsize)
{
x=st.elem[st.top[1]];
++(st.top[1]);
return 1;
}
}
else
return 0;
}