-
Notifications
You must be signed in to change notification settings - Fork 0
/
STL_Queue.cpp
75 lines (73 loc) · 1.86 KB
/
STL_Queue.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
queue<int> q;
while (true)
{
int x;
cout << endl
<< "Option 1: Push element into Queue" << endl
<< "Option 2: Pop element from Queue" << endl
<< "Option 3: View front" << endl
<< "Option 4: View size" << endl
<< "Option 5: Exit" << endl
<< endl
<< "Please enter an option: ";
cin >> x;
if (x == 1)
{
int v;
cout << endl
<< "Please enter a value: ";
cin >> v;
q.push(v);
cout << endl
<< "Value inserted to the Queue successfully." << endl;
}
else if (x == 2)
{
if (!q.empty())
{
q.pop();
cout << endl
<< "Popped element from Queue." << endl;
}
else
{
cout << endl
<< "Queue is empty." << endl;
}
}
else if (x == 3)
{
if (!q.empty())
{
cout << endl
<< "The front value is " << q.front() << endl;
}
else
{
cout << endl
<< "Queue is empty." << endl;
}
}
else if (x == 4)
{
cout << endl
<< "Size of the Queue is " << q.size() << endl;
}
else if (x == 5)
{
cout << endl
<< "Queue has been terminated, Thank you." << endl;
break;
}
else
{
cout << endl
<< "Invalid option." << endl;
}
}
return 0;
}