/* Queue implemention using two stack */
#include<stdio.h>
#include<stdlib.h>
#include"stack.h"
#define MAX 20
int main()
{
struct stack s1,s2;
int i,item;
int ch;
initstack(&s1);
initstack(&s2);
while(1)
{
printf("Enter 1. for Push\n");
printf("Enter 2. for pop\n");
printf("Enter 3. for exit.\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Enter item:");
scanf("%d",&item);
push(&s1,item);
break;
case 2:
if(isEmpty(&s2))
{
while(!isEmpty(&s1))
{
push(&s2,pop(&s1));
}
}
printf("poped element is %d",pop(&s2));
break;
case 3:
exit(1);
break;
default:
printf("Wrong Input\n");
}
}
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include"stack.h"
#define MAX 20
int main()
{
struct stack s1,s2;
int i,item;
int ch;
initstack(&s1);
initstack(&s2);
while(1)
{
printf("Enter 1. for Push\n");
printf("Enter 2. for pop\n");
printf("Enter 3. for exit.\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Enter item:");
scanf("%d",&item);
push(&s1,item);
break;
case 2:
if(isEmpty(&s2))
{
while(!isEmpty(&s1))
{
push(&s2,pop(&s1));
}
}
printf("poped element is %d",pop(&s2));
break;
case 3:
exit(1);
break;
default:
printf("Wrong Input\n");
}
}
return 0;
}