-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircularlinklist.cpp
More file actions
95 lines (84 loc) · 1.2 KB
/
circularlinklist.cpp
File metadata and controls
95 lines (84 loc) · 1.2 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
#include<iostream>
using namespace std;
class circular
{
class node
{
public:
int item;
class node *next;
};
public:
node *start,*ptr,*temp;
//public:
circular()
{
start=temp=ptr=NULL;
}
void create()
{
int c;
//start=NULL;
do
{
cout<<"enter the no:";
temp=new node;
cin>>temp->item;
cout<<endl;
if(start==NULL)
{
start=temp;
ptr=temp;
temp->next=start;
}
else
{
ptr->next=temp;
ptr=temp;
ptr->next=start;
}
cout<<"press 1 for continue:";
cin>>c;
}while(c==1);
}
void display(node *ptr)
{
// ptr=start;
cout<<"nos are :"<<" ";
do
{
cout<<ptr->item<<" ";
ptr=ptr->next;
}while(ptr!=start);
}
};
int main()
{
int c;
circular s;
do
{
cout<<"\n main menu "<<endl
<<"1.create"<<endl
<<"2.display"<<endl
<<"press 0 for exit"<<endl
<<"enter ur choice"<<endl;
//int c;
cin>>c;
switch(c)
{
case 1:
s.create();
break;
case 2:
s.display(s.start);
break;
default:
cout<<"error: try again";
}
//int k;
//cout<<"press 1 for continue";
//cin>>k;
}while(c!=0);
return 0;
}