structlist1
{
intvalue;
list1* next;
};
list1 * merge (list1 *list1_head, list1 *list2_head)
{
list1* head=NULL,*p=NULL;
if(list1_head->valuevalue)
{ head=list1_head;list1_head=list1_head->next;}
else
{ head=list2_head;list2_head=list2_head->next;}
p=head;
while(list1_head&&list2_head)
{
if(list1_head->valuevalue)
{ head->next=list1_head;head=list1_head;list1_head=list1_head->next;}
else
{ head->next=list2_head;head=list2_head;list2_head=list2_head->next;}
}
if(list2_head==NULL&&list1_head==NULL)
return p;
if(!list2_head)
head->next=list1_head;
if(!list1_head)
head->next=list2_head;
return p;
}