#include<iostream>
using namespace std;
#include<conio.h>
class link
{
public:
int info;
link *next;
link()
{
info=0;
next=0;
}
};
class node
{
private:
link *list;
public:
node()
{
list=NULL;
}
void insert(int a)
{
link* temp=new link();
temp->info=a;
temp->next=NULL;
if(list==NULL)
{
list=temp;
}
else
{
while(list->next!=NULL)
list=list->next;
list->next=temp;
}
}
void insert_mid(int a,int b)
{
link *temp=new link();
temp=list;
for(;temp->info!=b;temp=temp->next);
link *newtemp=new link();
newtemp->info=a;
newtemp->next=temp->next;
temp->next=newtemp;
}
void del_mid(int a)
{
link* temp=new link();
temp=list;
if(list->info==a)
{
list=list->next;
}
else
{
while(list->next->info!=a)
{
list=list->next;
}
list->next=list->next->next;
list=temp;
}
}
void show_list()
{
while(list!=NULL)
{
cout<<list->info;
list=list->next;
}
}
};
void main()
{
node *ob=new node();
ob->insert(5);
ob->insert(7);
ob->insert_mid(8,5);
ob->del_mid(8);
ob->show_list();
_getch();
}
using namespace std;
#include<conio.h>
class link
{
public:
int info;
link *next;
link()
{
info=0;
next=0;
}
};
class node
{
private:
link *list;
public:
node()
{
list=NULL;
}
void insert(int a)
{
link* temp=new link();
temp->info=a;
temp->next=NULL;
if(list==NULL)
{
list=temp;
}
else
{
while(list->next!=NULL)
list=list->next;
list->next=temp;
}
}
void insert_mid(int a,int b)
{
link *temp=new link();
temp=list;
for(;temp->info!=b;temp=temp->next);
link *newtemp=new link();
newtemp->info=a;
newtemp->next=temp->next;
temp->next=newtemp;
}
void del_mid(int a)
{
link* temp=new link();
temp=list;
if(list->info==a)
{
list=list->next;
}
else
{
while(list->next->info!=a)
{
list=list->next;
}
list->next=list->next->next;
list=temp;
}
}
void show_list()
{
while(list!=NULL)
{
cout<<list->info;
list=list->next;
}
}
};
void main()
{
node *ob=new node();
ob->insert(5);
ob->insert(7);
ob->insert_mid(8,5);
ob->del_mid(8);
ob->show_list();
_getch();
}