#include<iostream.h>
#include<conio.h>
struct node
{
int data;
struct node *link;
//struct header *hlink;
};
struct header
{
//int n;
char info[1000];
struct node *nlink;
};
void main()
{
int num;
struct node *temp,*ptr;
struct header *head,*start=NULL;
head=new header;
cout<<"Enter Head info: ";
cin>>head->info;
temp=new node;
temp->link=NULL;
temp->data=10;
if(start==NULL)
{
head->nlink=temp;
start=head;
}
for(int i=0;i<5;i++)
{
cout<<"Enter data in node:-";
cin>>num;
temp=new node;
temp->link=head->nlink;
head->nlink=temp;
temp->data=num;
}
cout<<"Data after insertion in header linked list:---";
cout<<head->info<<endl;
for(temp=head->nlink;temp!=NULL;temp=temp->link)
{
cout<<temp->data<<endl;
}
getch();
}
#include<conio.h>
struct node
{
int data;
struct node *link;
//struct header *hlink;
};
struct header
{
//int n;
char info[1000];
struct node *nlink;
};
void main()
{
int num;
struct node *temp,*ptr;
struct header *head,*start=NULL;
head=new header;
cout<<"Enter Head info: ";
cin>>head->info;
temp=new node;
temp->link=NULL;
temp->data=10;
if(start==NULL)
{
head->nlink=temp;
start=head;
}
for(int i=0;i<5;i++)
{
cout<<"Enter data in node:-";
cin>>num;
temp=new node;
temp->link=head->nlink;
head->nlink=temp;
temp->data=num;
}
cout<<"Data after insertion in header linked list:---";
cout<<head->info<<endl;
for(temp=head->nlink;temp!=NULL;temp=temp->link)
{
cout<<temp->data<<endl;
}
getch();
}
No comments:
Post a Comment