#include
struct Node
{
int data;
struct Node *next;
};
struct Node *create_list(int *ptr,int n)
{
struct Node *hptr=NULL,*tptr,*temp;
int i;
if(n>0)
{
hptr=(struct Node*)malloc(sizeof(struct Node));
tptr=hptr;
hptr->data=ptr[0];
for (i=1;idata=ptr[i];
temp->next=NULL;
tptr->next=temp;
tptr=temp;
}
}
return hptr;
}
char* rfind(struct Node *hptr,int d)
{
if(hptr==NULL)
return "NOT FOUND";
else
if(hptr->data==d)
return "FOUND";
else
return rfind(hptr->next,d);
}
void main()
{
int arr[]={10,12,53,84,35,16};
struct Node *hptr,*tptr;
hptr=create_list(arr,6);
printf("%s\n",rfind(hptr,45));
}
No comments:
Post a Comment