forked from CodingPsychos/data-structures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
126 lines (104 loc) · 2 KB
/
main.c
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <stdio.h>
#include <stdlib.h>
#include "dsa.c"
void main() {
queue* front=NULL;
queue* rear=NULL;
while(1){
printf("\na.push\nb.pop\nc.front\nq.quit\n");
char c;
scanf("\n%c",&c);
if(c=='q')
break;
switch(c){
case 'a':{
printf("enter data\n");
int s;
scanf("%d",&s);
enqueue(&front,&rear,s);
break;
}
case 'b':{
printf("\n%d removed\n",dequeue(&front,&rear));
break;
}
case 'c':{
printf("\nfront=%d\n",queue_get_front(&front,&rear));
break;
}
}
}}
/*
//list node
list_node* head=NULL;
list_node* tail=NULL;
while(1){
printf("\na.push\n"
"b.pop\n"
"c.shift\n"
"d.unshift\n"
"e.insert\n"
"f.delete\n"
"g.print\n"
"h.print in reverse\n"
"i.reverse list\n"
"q.quit\n"
);
char c;
scanf("\n%c",&c);
if(c=='q'){
break;
}
else{
switch(c){
case 'a':{
int a;
printf("Enter the value");
scanf("%d",&a);
list_push(&head,&tail,a);
break;}
case 'b':
list_pop(&head,&tail);
break;
case 'c':{
int a;
printf("Enter the value");
scanf("%d",&a);
list_shift(&head,&tail,a);
break;}
case 'd':
list_unshift(&head,&tail);
break;
case 'e':{
int v;
int p,n;
printf("Enter the position");
scanf("%d",&p);
printf("Enter the value");
scanf("%d",&n);
v=list_insert(&head,&tail,p,n);
printf("\n%d Value added",v);
break;
}
case 'f':{
int v;
int p;
printf("Enter the position");
scanf("%d",&p);
v=list_delete(&head,&tail,p);
printf("\n%d position removed",v);
break;
}
case 'g':
list_print(head);
break;
case 'h':
list_print_in_reverse(head);
break;
default:printf("Check the data entered");
case 'i':
list_reverse(&head);
break;
}
}
}*/