-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabCycle2-5Demo.cpp
56 lines (52 loc) · 1.7 KB
/
LabCycle2-5Demo.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
#include "LabCycle2-5.cpp"
int main() {
const int MAX_SIZE = 5;
DequeueArray<int, MAX_SIZE> dq;
int choice;
do {
cout << "\nDEQUEUE Operations:\n";
cout << "1. Insert Front\n";
cout << "2. Insert Rear\n";
cout << "3. Delete Front\n";
cout << "4. Delete Rear\n";
cout << "5. Is Empty\n";
cout << "6. Is Full\n";
cout << "7. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
int element;
cout << "Enter element to insert at front: ";
cin >> element;
dq.insertFront(element);
break;
}
case 2: {
int element;
cout << "Enter element to insert at rear: ";
cin >> element;
dq.insertRear(element);
break;
}
case 3:
cout << "Deleted element from front: " << dq.deleteFront() << endl;
break;
case 4:
cout << "Deleted element from rear: " << dq.deleteRear() << endl;
break;
case 5:
cout << (dq.isEmpty() ? "DEQUEUE is empty.\n" : "DEQUEUE is not empty.\n");
break;
case 6:
cout << (dq.isFull() ? "DEQUEUE is full.\n" : "DEQUEUE is not full.\n");
break;
case 7:
cout << "Exiting...\n";
break;
default:
cout << "Invalid choice. Please try again.\n";
}
} while (choice != 7);
return 0;
}