-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDLL.C
More file actions
98 lines (77 loc) · 1.48 KB
/
DLL.C
File metadata and controls
98 lines (77 loc) · 1.48 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<alloc.h>
struct node
{
struct node *prev;
int empno;
char name[20];
struct node *next;
};
struct node * getnode( )
{
return ( struct node *) malloc( sizeof( struct node ));
}
struct node * add( struct node *H )
{
struct node *N , *T;
N = getnode();
printf("Enter empno and name \n");
scanf("%d %s", &N->empno , N->name );
if( H == NULL )
{
H = N;
H->prev = H->next = H;
}
else
{
T = H;
while( T->next != H ) T = T->next;
T->next = N;
H->prev = N;
N->next = H;
N->prev = T;
}
return H;
}
void display ( struct node *T )
{
char ch;
while( 1 )
{
clrscr();
gotoxy( 35 , 10 );
printf("Employ number : %d \n", T->empno);
gotoxy( 35 , 12 );
printf("Employ name : %s \n", T->name );
printf("\n\n\n[N]ext [P]rev [Q]uit \n");
ch = getch();
if( ch == 'n' || ch == 'N') T = T->next;
else if( ch == 'p' || ch == 'P') T = T->prev;
else if( ch == 'q' || ch == 'Q' ) return;
}
}
void main()
{
struct node *H;
int ch;
H = NULL;
while(1)
{
clrscr();
printf("1. Addnew \n");
printf("2. Display \n");
printf("3. Exit \n");
scanf("%d", &ch );
switch( ch )
{
case 1:
H = add( H );
break;
case 2:
display( H );
break;
case 3:
exit(0);
}
getch();
}
}