-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_QUEUE_operations.cpp
91 lines (74 loc) · 1.25 KB
/
all_QUEUE_operations.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
using namespace std;
#define MAX 10
int front = -1, queue[MAX], rear = -1;
int enque();
int deque();
int display();
int main()
{
int n;
while (1)
{
cout << "-----Queue MEnu-----\n1-Enque\n2-Deque\n3-Display\n-Exit\n\n>>";
cin >> n;
switch (n)
{
case 1:
enque();
break;
case 2:
deque();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
cout << "Wrong choice\n";
}
}
return 0;
}
int enque()
{
int n;
if (front == MAX)
{
cout << "Queue Overflow\n";
}
else
{
if (front == -1)
front = 0;
cout << "Enter the number \n";
cin >> n;
rear += 1;
queue[rear] = n;
}
return 0;
}
int deque()
{
if (front == -1)
{
cout << "Queue Underflow\n";
return 0;
}
else
{
cout << "deleted item is " << queue[front] << endl;
front++;
}
}
int display()
{
if (front == -1)
cout << "Queue Underflow";
for (int i = front; i <= rear; i++)
{
cout << queue[i] << endl;
}
return 0;
}