#include<iostream>
using namespace std;
struct node
{
int data;
struct node *next;
}*start,*temp;
void Create()
{
int n;
cin>>n;
start=NULL;
while(n--)
{
node *new_node= new node;
cin>>new_node->data;
new_node->next=0;
if(start==NULL)
{
start=new_node;
temp=new_node;
}
else
{
temp->next=new_node;
temp=new_node;
}
}
}
int main()
{
Create();
int num;
cin>>num;
temp=start;
while(temp!=0)
{
if(temp->data==num)
{
start=temp;
break;
}
temp=temp->next;
}
if(temp==0)
{
cout<<"Invalid Node! "<<endl;
}
temp=start;
cout<<"Linked List : ";
while(temp!=0)
{
cout<<"->"<<temp->data;
temp=temp->next;
}
}
using namespace std;
struct node
{
int data;
struct node *next;
}*start,*temp;
void Create()
{
int n;
cin>>n;
start=NULL;
while(n--)
{
node *new_node= new node;
cin>>new_node->data;
new_node->next=0;
if(start==NULL)
{
start=new_node;
temp=new_node;
}
else
{
temp->next=new_node;
temp=new_node;
}
}
}
int main()
{
Create();
int num;
cin>>num;
temp=start;
while(temp!=0)
{
if(temp->data==num)
{
start=temp;
break;
}
temp=temp->next;
}
if(temp==0)
{
cout<<"Invalid Node! "<<endl;
}
temp=start;
cout<<"Linked List : ";
while(temp!=0)
{
cout<<"->"<<temp->data;
temp=temp->next;
}
}
This comment has been removed by the author.
ReplyDelete