void merge (LinkList La, LinkList Lb)
{
    LNode *tmp, *pa = La->next, *pb = Lb->next;
    La->next = NULL;
    for (pa && pb)
    {
        if (pa->data <= pb->data)
        {
            tmp = pa->next;
            pa->next = La->next;
            La->next = pa;
            pa = tmp;
        }
        else
        {
            tmp = pb->next;
            pb->next = La->next;
            La->next = pb;
            pb = tmp;
        }
        if (pb) pa = pb;
        while (pa)
        {
            tmp = pa->next;
            pa->next = La->next;
            La->next = pa;
            pa = tmp;
        }
    }
    free (Lb);
}
Comments
Write a Comment