Posts

Showing posts from February, 2016

merge two linklist

#include<stdio.h> struct node {   int data;   struct node *next; }; struct node *start1=NULL; struct node *start2=NULL; struct node *start3=NULL; struct node * create_list(struct node *start) {int n;   struct node *ptr;   printf("\n enter how many element you want to insert");   scanf("%d",&n);   while(n!=0)   {     n--;     printf("\n enter data");     ptr=(struct node*)malloc(sizeof(struct node));     scanf("\n%d",&ptr->data);     if(start==NULL)     {         start=ptr;         ptr->next=NULL;     }     else     {         ptr->next=start;         start=ptr;     }   }   return start; } void display(struct node *temp1) {     struct node *temp;     temp=temp1;     if(temp==NULL)     {         printf("list is empty");     }     else     {     while(temp!=NULL)     {       printf("\t %d",temp->data);       temp=temp->next;     }     } } void merge(st