#include<iostream>
using namespace std;
struct node
{
int data;
struct node *next;
}*head,*temp;
bool search(int a)
{
temp=head;
while(temp!=0)
{
if(a==temp->data)
return 1;
temp=temp->next;
}
return 0;
}
int main()
{
int n,X;
bool status;
cin>>n;
head=0;
while(n--)
{
struct node* new_node =(struct node*) malloc(sizeof(struct node));
cin>>new_node->data;
new_node->next=0;
if(head==0)
{
head=temp=new_node;
}
else
{
temp->next=new_node;
temp=new_node;
}
}
cin>>X;
status=search(X);
if(status==1)
{
cout<<"Yes";
}
else
cout<<"No";
return 0;
}
using namespace std;
struct node
{
int data;
struct node *next;
}*head,*temp;
bool search(int a)
{
temp=head;
while(temp!=0)
{
if(a==temp->data)
return 1;
temp=temp->next;
}
return 0;
}
int main()
{
int n,X;
bool status;
cin>>n;
head=0;
while(n--)
{
struct node* new_node =(struct node*) malloc(sizeof(struct node));
cin>>new_node->data;
new_node->next=0;
if(head==0)
{
head=temp=new_node;
}
else
{
temp->next=new_node;
temp=new_node;
}
}
cin>>X;
status=search(X);
if(status==1)
{
cout<<"Yes";
}
else
cout<<"No";
return 0;
}
This comment has been removed by the author.
ReplyDeleteOnly 83% successs
ReplyDelete#include
ReplyDeleteusing namespace std;
struct node
{
int data;
struct node *next;
}*head,*temp;
bool search(int a)
{
temp=head;
while(temp!=0)
{
if(a==temp->data)
return 1;
temp=temp->next;
}
return 0;
}
int main()
{
int n,X;
bool status;
cin>>n;
head=0;
while(n--)
{
struct node* new_node =(struct node*)malloc(sizeof(struct node));
cin>>new_node->data;
new_node->next=0;
if(head==0)
{
head=temp=new_node;
}
else
{
temp->next=new_node;
temp=new_node;
}
}
cin>>X;
status=search(X);
if(status==1)
{
cout<<"Yes";
}
else
cout<<"No";
return 0;
}
#include
ReplyDeleteusing namespace std;
struct node
{
int data;
struct node*next;
}*head,*temp;
bool search(int a)
{
temp=head;
while(temp!=0)
{
if(a==temp->data)
return 1;
temp=temp->next;
}
return 0;
}
int main()
{
int N,x;
bool status;
cin>>N;
head=0;
while(N--)
{
struct node* new_node=(struct node*)malloc(sizeof(struct node));
cin>>new_node->data;
new_node->next=0;
if(head==0)
{
head=temp=new_node;
}
else
{
temp->next=new_node;
temp=new_node;
}
}
cin>>x;
status=search(x);
if(status==1)
{
cout<<"Yes";
}
else
cout<<"No";
return 0;
}
this works
Delete