-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathQueue_stack.c
More file actions
49 lines (47 loc) · 739 Bytes
/
Queue_stack.c
File metadata and controls
49 lines (47 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "liststack.h"
#include<stdlib.h>
#include<stdio.h>
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);
}