/*
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: THIS PROGRAMM INDICATES THE CONCEPT OF CIRCULER ::::
:::: LINKED LIST ::::
:::: CREATED BY : DX PANCHAL(M.C.A.) DATED:08/03/2013 ::::
:::: PROGRAMMING LANGUAGE : c++ ::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/
#include<iostream.h>
#include<conio.h>
#include<malloc.h>
#include<dos.h>
#include<process.h>
struct list
{
int info;
struct list *next;
};
typedef struct list *newnode;
newnode first,newn,temp,save,avail,head,pred;
void main()
{
int ch,i,choice;
textcolor(WHITE);
clrscr();
first=NULL;
avail=(newnode)malloc(sizeof(struct list));
avail->next=NULL;
cout<<"\n\t\tENTER VALUES YOU WANT TO CREATE NODE\n";
cin>>ch;
temp=avail;
for(i=1;i<ch;i++)
{
temp->next=(newnode)malloc(sizeof(struct list));
temp=temp->next;
temp->next=NULL;
}
cout<<"\n\t\tYOU HAVE "<<ch<<" NODE SUCCESSFULLY CREATED....!!!";
getch();
do
{
clrscr();
cout<<"\n\t\t ";
cout<<"\n\t\t| CIRCLUER LINKED LIST MENU |";
cout<<"\n\t\t|________________________________|\n";
cout<<"\n\t\t ";
cout<<"\n\t\t[1] FOR INSERT NODE ";
//cout<<"\n\t\t[3] FOR INSERT NODE AS ORDER ";
// cout<<"\n\t\t[4] FOR DELETE NODE AT FIRST ";
//cout<<"\n\t\t[5] FOR DELETE NODE AT LAST ";
cout<<"\n\t\t[2] FOR DELETE NODE ";
cout<<"\n\t\t[3] FOR DISPLAY NODE LIST ";
cout<<"\n\t\t[0] FOR EXIT ";
cout<<"\n\t\t ";
cin>>choice;
switch(choice)
{
case 1:
if(avail==NULL)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("NO NODE AVAILABLE FOR INSERT OPERATION..!!!");
textcolor(WHITE);
}
else
{
newn=avail;
avail=avail->next;
cout<<"\n\t\tENTER VALUE FOR NODE ";
cin>>newn->info;
if(first==NULL)
{
head->info=NULL;
newn->next=NULL;
first=newn;
head->next=first;
}
else
{
save=first;
while(save->next!=head)
{
save=save->next;
}
save->next=newn;
newn->next=head;
}
cout<<"\n\t\tOPERATION SUCCESSFULL..!!!";
}
getch();
break;
case 2:
if(first==NULL)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("NO NODE AVAILABLE FOR DELETE OPERATION..!!!");
textcolor(WHITE);
}
else
{
temp=first;
int selected;
cout<<"\n\t\tENTER NODE DATA WHICH YOU WANT TO DELETE..!!!";
cin>>selected;
while(temp->info!=selected&&temp!=NULL)
{
pred=temp;
temp=temp->next;
}
pred->next=temp->next;
if(temp->info!=selected)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("OH,SORRY SELECTED NODE NOT FOUND..!!!");
textcolor(WHITE);
}
else
{
cout<<"\n\t\tSELECTED NODE |"<<temp->info<<"| IS DELETED SUCCESSFULLY...!!!";
avail=temp->next;
avail=temp;
}
}
getch();
break;
case 3:
cout<<"\n\t\t ";
cout<<"\n\t\t TOTAL NODE IN LIST";
if(first==NULL)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("NO NODE AVAILABLE FOR DISPLAY OPERATION..!!!");
textcolor(WHITE);
}
else
{
temp=first;
while(temp!=head)
{
cout<<"\n\n\t\t";
//cout<<i;
cout<<" ";
cout<<temp->info;
temp=temp->next;
}
}
cout<<"\n\t\t ";
getch();
break;
case 0: cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("PRESS ANY KEY TO EXIT..!!!");
textcolor(WHITE);
getch();
exit(0);
default:
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("INVALID CHOICE..!!!");
textcolor(WHITE);
getch();
}
}while(choice!=0);
}
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: THIS PROGRAMM INDICATES THE CONCEPT OF CIRCULER ::::
:::: LINKED LIST ::::
:::: CREATED BY : DX PANCHAL(M.C.A.) DATED:08/03/2013 ::::
:::: PROGRAMMING LANGUAGE : c++ ::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/
#include<iostream.h>
#include<conio.h>
#include<malloc.h>
#include<dos.h>
#include<process.h>
struct list
{
int info;
struct list *next;
};
typedef struct list *newnode;
newnode first,newn,temp,save,avail,head,pred;
void main()
{
int ch,i,choice;
textcolor(WHITE);
clrscr();
first=NULL;
avail=(newnode)malloc(sizeof(struct list));
avail->next=NULL;
cout<<"\n\t\tENTER VALUES YOU WANT TO CREATE NODE\n";
cin>>ch;
temp=avail;
for(i=1;i<ch;i++)
{
temp->next=(newnode)malloc(sizeof(struct list));
temp=temp->next;
temp->next=NULL;
}
cout<<"\n\t\tYOU HAVE "<<ch<<" NODE SUCCESSFULLY CREATED....!!!";
getch();
do
{
clrscr();
cout<<"\n\t\t ";
cout<<"\n\t\t| CIRCLUER LINKED LIST MENU |";
cout<<"\n\t\t|________________________________|\n";
cout<<"\n\t\t ";
cout<<"\n\t\t[1] FOR INSERT NODE ";
//cout<<"\n\t\t[3] FOR INSERT NODE AS ORDER ";
// cout<<"\n\t\t[4] FOR DELETE NODE AT FIRST ";
//cout<<"\n\t\t[5] FOR DELETE NODE AT LAST ";
cout<<"\n\t\t[2] FOR DELETE NODE ";
cout<<"\n\t\t[3] FOR DISPLAY NODE LIST ";
cout<<"\n\t\t[0] FOR EXIT ";
cout<<"\n\t\t ";
cin>>choice;
switch(choice)
{
case 1:
if(avail==NULL)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("NO NODE AVAILABLE FOR INSERT OPERATION..!!!");
textcolor(WHITE);
}
else
{
newn=avail;
avail=avail->next;
cout<<"\n\t\tENTER VALUE FOR NODE ";
cin>>newn->info;
if(first==NULL)
{
head->info=NULL;
newn->next=NULL;
first=newn;
head->next=first;
}
else
{
save=first;
while(save->next!=head)
{
save=save->next;
}
save->next=newn;
newn->next=head;
}
cout<<"\n\t\tOPERATION SUCCESSFULL..!!!";
}
getch();
break;
case 2:
if(first==NULL)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("NO NODE AVAILABLE FOR DELETE OPERATION..!!!");
textcolor(WHITE);
}
else
{
temp=first;
int selected;
cout<<"\n\t\tENTER NODE DATA WHICH YOU WANT TO DELETE..!!!";
cin>>selected;
while(temp->info!=selected&&temp!=NULL)
{
pred=temp;
temp=temp->next;
}
pred->next=temp->next;
if(temp->info!=selected)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("OH,SORRY SELECTED NODE NOT FOUND..!!!");
textcolor(WHITE);
}
else
{
cout<<"\n\t\tSELECTED NODE |"<<temp->info<<"| IS DELETED SUCCESSFULLY...!!!";
avail=temp->next;
avail=temp;
}
}
getch();
break;
case 3:
cout<<"\n\t\t ";
cout<<"\n\t\t TOTAL NODE IN LIST";
if(first==NULL)
{
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("NO NODE AVAILABLE FOR DISPLAY OPERATION..!!!");
textcolor(WHITE);
}
else
{
temp=first;
while(temp!=head)
{
cout<<"\n\n\t\t";
//cout<<i;
cout<<" ";
cout<<temp->info;
temp=temp->next;
}
}
cout<<"\n\t\t ";
getch();
break;
case 0: cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("PRESS ANY KEY TO EXIT..!!!");
textcolor(WHITE);
getch();
exit(0);
default:
cout<<"\n\t\t";
textcolor(RED+BLINK);
cprintf("INVALID CHOICE..!!!");
textcolor(WHITE);
getch();
}
}while(choice!=0);
}
nice
ReplyDeleteThanks tanmay
ReplyDeletegood
ReplyDelete