DFS :: CIRCULAR

#include<iostream.h>
#include<conio.h>
struct node
{
int n;
node *p;
};

class link
{
node *a,*b,*h,c;
char ans;

public:
void create();
void display();

};
void link::create()
{

h=NULL;
do
{
a=new node;
cout<<“enter the value”;
cin>>a->n;
a->p=NULL;
if(h==NULL)
{
h=a;
b=a;

}
else
{
b->p=a;
b=a;
}

cout<<“do u want to enter the value:”;
cin>>ans;

}while(ans==’Y’||ans==’y’);
b->p=h;
}
void link::display()
{
a=h;
do
{
cout<<a->n<<“->”;
a=a->p;
}while(a!=h);
}
main()
{
clrscr();
link ob;
ob.create();
ob.display();
getch();
}

Share

About the Author

Akash Padhiyar

Visit Website

There are no comments yet, add one below.

Leave a Comment

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload CAPTCHA.