链表问题 想不通 请大神指教 万分感谢
设有a,b两个链表,每个链表中的节点包括学号·成绩。要求将两个链表合并为一个链表,按学号升序排列
struct student *insert(struct student *ah,struct student *bh)
{struct student *pa1 , *pa2,*pb1,*pb2;
pa2=pa1=ah;
pb2=pb1=bh;
do
{while((pb1->num>pa1->num)&&(pa1->next!=NULL))
{pa2=pa1;
pa1=pa1->next;
}
if(pb->num<=pa1->num)
{if(ah=pa1)
ah=pb1;
else pa2->next=pb1;
pb1=pb1->next;
pb2->next=pa1;
pa2=pb2;
pb2=pb1;
}
}
谁给我讲讲思路 万分感谢