#include "stdafx.h"
#include
using namespace std;
typedef struct liu
{
int data; struct liu*next;
}test,*LinkList;
liu *p,*pa,*pb,*pc,*La,*Lb,*Lc;
int m=sizeof(test);
void build(LinkList &L)
{ int i,j;
cout<<"how many lnode do you need?"<
L=(test*)malloc(m);
L->next=(LinkList)malloc(m);
p=L->next;
cout<<"enter these nodes:"<
cin>>p->data;
p->next=(test*)malloc(m);
p=p->next;
}
cin>>p->data;
p->next=NULL ;}
void MergeList_L(LinkList &La,LinkList &Lb,LinkList &Lc)
{
pa=La->next; pb=Lb->next; Lc=pc=La;
while(pa&&pb)
{
if(pa->data <= pb->data)
{
pc->next=pa; pc=pa; pa=pa->next;
}
else
{
pc->next=pb; pc=pb; pb=pb->next;}
}
pc->next = pa?pa:pb ;
free(Lb);
}
void display(LinkList &L)
{p=L;
cout<<"the new list is:"<
{
cout<
}
cout<
void main()
{
build(La);
build(Lb);
MergeList_L(La,Lb,Lc);
display(Lc);
}