typedef struct
{
ElemType data;
int top;
}SqStack;
bool EnQueue(SqStack &S1,SqStack &S2,int x)
{
int t;
if(S1.top<max-1)
{
Push(S1,x);
return true;
}
if(S1.top==max-1&&!IsEmpty(S2))
return false;
if(S1.top==max-1&&IsEmpty(S2))
{
while(!IsEmpty(S1))
{
Pop(S1,t);
Push(S2,t);
}
}
Push(S1,x);
return true;
}
bool DeQueue(SqStack &S1,SqStack &S2,int &x)
{
int t;
if(!Isempty(S2))
{
Pop(S2,t);
return true;
}
else if(Isempty(S1))
return false;
else
{
while(!Isempty(S1))
{
Pop(S1,t);
Push(S2,t);
}
Pop(S2,x);
}
}
bool IsEmptyQueue(SqStack S1,SqStack S2)
{
if(IsEmpty(S1)&&IsEmpty(S2))
return true;
else
return false;
}