typedef struct Node
{
struct Node* next;
int data;
}Node,*LNode;
void combine(LNode &head,LNode aL,LNode bL)
{
if(NULL==aL)
{
head = bl;
return;
}
if(NULL==bl)
{
head =al;
return;
}
Node*p,*q,*r;
p = al;
q = bl;
if(p->data<q->data)
{
head = q;
q = q->next;
}
else
{
head = p;
p = p->next;
}
r = head;
while(p&&q)
{
if(p->data>q->data)
{
r->next = p;
r = p;
p = p->next;
}
else
{
r->next = q;
r = q;
q = q->next;
}
}
if(NULL!=p)
{
r->next = p;
r = p;
p = p->next;
}
if(NULL!=q)
{
r->next = q;
r = q;
q = q->next;
}
}
合并链表
最新推荐文章于 2021-05-18 22:52:35 发布