-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabCycle1-4Demo.cpp
62 lines (58 loc) · 1.84 KB
/
LabCycle1-4Demo.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
#include "LabCycle1-4.cpp"
int main() {
LinkedList<int> list;
int choice;
int value, pos;
do {
cout << "\nMenu:\n";
cout << "1. Insert at Beginning\n";
cout << "2. Insert at End\n";
cout << "3. Insert at a specified Position\n";
cout << "4. Delete from Beginning\n";
cout << "5. Delete from End\n";
cout << "6. Delete from a specified Position\n";
cout << "7. Display\n";
cout << "0. Quit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "Enter value to insert at beginning: ";
cin >> value;
list.insertAtBeginning(value);
break;
case 2:
cout << "Enter value to insert at end: ";
cin >> value;
list.insertAtEnd(value);
break;
case 3:
cout << "Enter position to insert: ";
cin >> pos;
cout << "Enter value to insert: ";
cin >> value;
list.insertAtPosition(pos, value);
break;
case 4:
list.deleteFromBeginning();
break;
case 5:
list.deleteFromEnd();
break;
case 6:
cout << "Enter position to delete: ";
cin >> pos;
list.deleteFromPosition(pos);
break;
case 7:
list.display();
break;
case 0:
cout << "Exiting...";
break;
default:
cout << "Invalid choice. Please enter again." << endl;
}
} while (choice != 0);
return 0;
}