void EnQueue(Stack *s1, Stack *s2, int k)
{
Push(s1, k);
}
int DeQueue(Stack *s1, Stack*s2)
{
if(IsStackEmpty(s2) == 1)
{
while(IsStackEmpty(s1) == 0)
{
Push(s2, Pop(s1));
}
}
if(IsStackEmpty(s2) == 1)
{
printf("Empty!\n");
}
return Pop(s2);
void Push(Queue *q1, Queue *q2, int k)
{
EnQueue(q1, k);
}
int Pop(Queue *q1, Queue *q2)
{
int tmp;
if(IsQueueEmpty(q1) == 1)
{
printf("Stack Empty!\n");
}
else
{
while(SizeOfQueue(q1) != 1)
{
EnQueue(q2, DeQueue(q1));
}
tmp = DeQueue(q1);
while(IsQueueEmpty(q2) == 0)
{
EnQueue(q1, DeQueue(q2));
}
return tmp;
}
}
void Push(Queue *q1, Queue *q2, int k)
{
Queue *pushtmp;
if(!IsQueueEmpty(q1))
{
pushtmp = q1;
}
else
{
pushtmp = q2;
}
EnQueue(pushtmp, k);
}
int Pop(Queue *q1, Queue *q2)
{
int tmpvalue;
Queue *pushtmp, *tmp;
if(!IsQueueEmpty(q1))
{
pushtmp = q1;
tmp = q2;
}
else
{
pushtmp = q2;
tmp = q1;
}
if(IsQueueEmpty(pushtmp))
{
printf("Stack Empty!\n");
}
else
{
while(SizeOfQueue(pushtmp) != 1)
{
EnQueue(tmp, DeQueue(pushtmp));
}
tmpvalue = DeQueue(pushtmp);
return tmpvalue;
}
}