-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA-CLLMain.cpp
More file actions
78 lines (78 loc) · 1.64 KB
/
DSA-CLLMain.cpp
File metadata and controls
78 lines (78 loc) · 1.64 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
78
#include "DSA.h"
int main()
{
int choice;
printf("Welcome!\nEnter-\n1\t-\t to Add a Node in the beggining\n2\t-\t to Add a Node in the end\n3\t-\t to Add a Node at a specific position\n4\t-\t to Delete a Node from the beggining \n5\t-\t to Delete a Node from the end \n6-\t-\t to Delete a Node at a specific position\n7-\t-\t to display the list\n8-\t-\t to search a value in the list\nOr Any character to exit\n");
scanf("%d",&choice);
int flag=0;
while(flag==0)
{
switch(choice)
{
case 1: addNodeB();
break;
case 2: addNodeE();
break;
case 3:
{
int p;
printf("Enter the desired positon\n");
display();
scanf("%d",&p);
if(p>c)
printf("Invalid position\n");
else
{
if(p==1)
addNodeB();
else if(p==c)
addNodeE();
else
addNodeP(p);
}
break;
}
case 4: delNodeB();
break;
case 5: delNodeE();
break;
case 6:
{
int p;
printf("Enter the desired positon\n");
display();
scanf("%d",&p);
if(p>c+1)
printf("Invalid position\n");
else
{
if(p==1)
delNodeB();
else if(p==c+1)
delNodeE();
else
delNodeP(p);
}
break;
}
case 7: display();
break;
case 8:
{
int p;
printf("Enter the search value\n");
scanf("%d",&p);
search(p);
break;
}
default:printf("Thank You!\n");
flag=1;
}
if(flag==0)
{
printf("Enter Choice\n");
scanf("%d",&choice);
}
}
return 1;
}