-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLLtrasversion.cpp
61 lines (61 loc) · 1.05 KB
/
CLLtrasversion.cpp
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>
struct node
{
int data;
struct node *next;
}*tail,*temp,*newnode;
void CreateCLL()
{
int choice = 1;
printf("Create a circular linklist ^~^\n");
while(choice)
{
newnode=(struct node*)malloc(sizeof(struct node));
printf("Enter data : ");
scanf("%d",&newnode->data);
newnode->next=0;
if(tail==0)
{
tail=newnode;
tail->next=newnode;
}
else
{
newnode->next=tail->next;
tail->next=newnode;
tail=newnode;
}
printf("Do U want to continue 1/0 : ");
scanf("%d",&choice);
}
printf("\nFor Conformation list starts From : (%d",tail->next->data);
printf(")\n");
}
Display()
{
int count=1;
if(tail==0)
{
printf("\nList is Empty *~* ");
}
else
{
temp=tail->next;
printf("\nCreated Circular Linklist : ");
while(temp->next!=tail->next)
{
printf("%d->",temp->data);
temp = temp->next;
count++;
}
printf("%d",temp->data);
printf("\nCount Value : %d",count);
}
}
int main()
{
CreateCLL();
Display();
return 0;
}