
入队
//入队
int EnQueue(Stack &s1,Stack &s2,Elemtype e){
if(!StackFull(s1)){
push(s1,e);
return 1;
}
if(StackFull(s1) && !StackEmpty(s2)){
printf("队满");
return 0;
}
if(StackFull(s1) && StackEmpty(s2)){
while(!StackEmpty(s1)){
pop(s1,x);
push(s2,x);
}
}
push(s1,e);
return 1;
}
出队
//出队
void DeQueue(Stack &s1,Stack &s2,Elemtype &x){
if(!StackEmpty(s2)){
pop(s2,x);
}
else if(StackEmpty(s1)){
printf("队空");
}
else{
while(!StackEmpty(s1)){
pop(s1,x);
push(s2,x);
}
pop(s2,x);
}
}
判空
//判空
int QueueEmpty(Stack s1,Stack s2){
if(StackEmpty(s1) && StackEmpty(s2)) return 1;
else return 0;
}