-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkedList.cpp
More file actions
78 lines (75 loc) · 1.92 KB
/
linkedList.cpp
File metadata and controls
78 lines (75 loc) · 1.92 KB
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
#include "linkedList.h"
int main()
{
linkedList <int>l;
while(1)
{
int option;
cout<<"Press 1: addAtHead"<<endl;
cout<<"Press 2: insertAtSpecificLocation"<<endl;
cout<<"Press 3: addAtTail"<<endl;
cout<<"Press 4: deleteAtSpecificLocation"<<endl;
cout<<"Press 5: searchAndDelete"<<endl;
cout<<"Press 6: display"<<endl;
cout<<"Press 7: exit"<<endl;
cin>>option;
switch(option)
{
case 1:
{
int temp;
cout<<"Enter the element to be inserted. ";
cin>>temp;
l.addHead(temp);
break;
}
case 2:
{
int temp;
int location;
cout<<"Enter the element to be inserted. ";
cin>>temp;
cout<<"At what location? ";
cin>>location;
l.insertAt(location, temp);
break;
}
case 3:
{
int temp;
cout<<"Enter the element to be inserted. ";
cin>>temp;
l.addTail(temp);
break;
}
case 4:
{
int location;
cout<<"Enter the location to be deleted. ";
cin>>location;
l.deleteAt(location);
break;
}
case 5:
{
int temp;
cout<<"Enter the element to be deleted. ";
cin>>temp;
l.del(temp);
break;
}
case 6:
{
l.display();
break;
}
case 7:
{
return 0;
}
default:
cout<<"Invalid option."<<endl;
}
}
return 0;
}