forked from Aashutoshsharma002/algo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
doubly.c
61 lines (61 loc) · 1.28 KB
/
doubly.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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
struct node * prev;
int info;
struct node * next;
}*new_node,*start,*last,*temp;
void create()
{
int value,choice;
do
{
new_node=(struct node*)malloc(sizeof(struct node));
printf("enter element : ");
scanf("%d",&value);
new_node->prev=NULL;
new_node->info=value;
new_node->next=NULL;
if (start==NULL)
{
start = new_node;
last = new_node;
}
else
{
last->next=new_node;
new_node->prev=last;
last=new_node;
}
printf("aaje jaane ke liye 1 dabaye ya 0 dabaker nikle : ");
scanf("%d",&choice);
} while (choice==1);
}
void display()
{ temp = start;
printf("linklist in right direction : NULL<->");
while(temp->next!=NULL)
{
printf("%d<->",temp->info);
temp=temp->next;
}
printf("%d<->",temp->info);
printf("NULL\n");
printf("linklist in left direction : NULL<->");
// temp=last;
while(temp->prev!=NULL)
{
printf("%d<->",temp->info);
temp=temp->prev;
}
printf("%d<->",temp->info);
printf("null\n");
}
int main()
{
create();
display();
return 0;
}