-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircular linked list.c
More file actions
72 lines (62 loc) · 914 Bytes
/
circular linked list.c
File metadata and controls
72 lines (62 loc) · 914 Bytes
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
#include<stdio.h>
#include<stdlib.h>
struct node
{
int d;
struct node *next;
};
typedef struct node node;
node *head=NULL;
void insert(int x)
{
node *t=(node *)malloc(sizeof(node));
t->d=x;
t->next=head;
if(head==NULL)
{head=t;
t->next=head;
}
else
{
node *te=head;
while(te->next!=head)
{
te=te->next;
}
te->next=t;
}
}
void in5()
{
node *t=(node *)malloc(sizeof(node));
t->d=5;
t->next=NULL;
node *t1=head,*t2;
while(t1->d<=5 && t1->next!=head)
{
t2=t1;
t1=t1->next;
}
t2->next=t;
t->next=t1;
}
void print()
{
node *t=head;
while(t->next!=head)
{
printf("%d ",t->d);
t=t->next;
}
}
void main()
{
int x=1;
while(x)
{
scanf("%d",&x);
insert(x);
}
in5();
print();
}