Professional Documents
Culture Documents
Double A,$j&r
Double A,$j&r
Double A,$j&r
#include<iomanip>
struct student
{ int id;
string name;
};
void insertfirst()
cin>>temp->name;
temp->next=NULL;
temp->perv=NULL;
if(head==NULL)
head=temp;
else
temp1=head;
head=temp;
temp->next=temp1;
temp1->perv=temp;
cin>>temp->name;
temp->next=NULL;
temp->perv=NULL;
if(head==NULL) head=temp;
else { while(temp->next!=NULL)
{temp=temp->next;
}temp->next=(new student);
(new student)->perv=temp;
(new student)->next=NULL;}
void insertend()
temp=new student;
cin>>temp->name;
temp->next=NULL;
temp->perv=NULL;
if(head==NULL)
head=temp;
last=temp;
else
last->next=temp;
temp->next=last;
last=temp;
void delete_first()
if(head == NULL)
else
temp=head;
head=temp->next;
delete(temp);
void delete_end()
if(head == NULL)
else
temp=head;
while(temp->next!= NULL)
temp1=temp;
temp=temp->next;
delete(temp);
temp1->next=NULL;
void display()
{
struct student *temp=head;
if(head == NULL)
cout<<"Empty list"<<endl;
else{
cout<<"===============================================================================
======="<<endl;
cout<<setw(10)<<"Name"<<endl;
cout<<"===============================================================================
======="<<endl;
while(temp != NULL)
cout<<setw(10)<<temp->name<<endl;
temp=temp->next;
int choice;
do
cout<<"6.Display"<<endl;
cout<<".Exit"<<endl;
cin>>choice;
switch(choice)
case 1:insertfirst();break;
case 2:insertend();break;
case 3:insert_atmid(2);break;
case 4:delete_first();break;
case 5:delete_end();break;
case 6:display();break;
case 7:repeat=1;break;
default:cout<<"Wrong Choice"<<endl;
}while(repeat==0);
return 0;}