void
add(
int
x)
{
if
(first==NULL)
{
node *temp=
new
node;
first=temp;
first->data=x;
cout<<
"\nEnter Name : "
;
cin>>first->name;
first->next=NULL;
last=first;
}
else
{
node *temp=
new
node;
last->next=temp;
last=temp;
last->data=x;
cout<<
"\nEnter Name : "
;
cin>>last->name;
last->next=NULL;
}
}
void
del(
int
y)
{
if
(y==first->data)
{
node *temp;
temp=first->next;
delete
first;
first=temp;
}
else
if
(y==last->data)
{
node *temp,*temp1;
temp=temp1=first;
while
(1)
{
temp1=temp;
temp=temp->next;
if
(temp==last)
{
delete
last;
last=temp1;
last->next=NULL;
break
;
}
}
}
else
{
node *temp,*temp1;
temp=temp1=first;
while
(1)
{
temp1=temp;
temp=temp->next;
if
(temp->data==y)
{
temp1->next=temp->next;
delete
temp;
break
;
}
}
}
}
void
show()
{
node *n = first;
while
( n ) {
cout << n->data <<
" "
<<n->name<<
"\n"
;
n = n->next;
}
cout <<
'\n'
;
}
void
format()
{
node *n = first;
node *e = first;
while
( n ) {
e=n;
n = n->next;
delete
e;
}
}
void
searchlist(
int
l)
{
node *n = first;
while
( 1 ) {
if
(n->data==l)
{
cout << n->data <<
" "
<<n->name<<
"\n"
;
break
;
}
else
{
n = n->next;
}
}
}