From 026ab305245da1c7c17a80d2a20cc84e1f279c0f Mon Sep 17 00:00:00 2001 From: kailasaps <43422245+kailasaps@users.noreply.github.com> Date: Mon, 22 Oct 2018 21:29:33 +0530 Subject: [PATCH] Create queue_stack.c --- queue_stack.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 queue_stack.c diff --git a/queue_stack.c b/queue_stack.c new file mode 100644 index 0000000..370dbaf --- /dev/null +++ b/queue_stack.c @@ -0,0 +1,51 @@ + + #include "Linked_Stack.h" + #include + #include + void main() + { + struct node *top1=createstack(); + int temp,ch; + do + { + printf("enter the choice 1.push 2.pop 3.exit"); + scanf("%d",&ch); + switch(ch) + { + case 1: + printf("enter the element to be pushed"); + scanf("%d",&temp); + push(temp,top1); + break; + case 2: + printf("Deleted element is"); + node *top2=createstack(); + while(1) + { + temp=pop(top1); + if(peek(top1)) + push(temp,top2); + else + { + if(temp==0) + printf("empty"); + else + printf("%d\n",temp); + break; + } + } + while(1) + { + temp=pop(top2); + if(temp) + push(temp,top1); + else + break; + + } + break; + } + }while(ch!=3); + + + }