问个关于链表合并的问题
请帮忙看下以下程序错没错,谢谢srtuct stu
{
int no;
struct stu *next;
};
struct stu *insert(struct stu *ah,struct stu *bh)//ah和bh两个链表合并,按学号升序排列
{
struct stu *pa1,*pa2,*pb1,*pb2;
pa1=pa2=ah;
pb1=pb2=bh;
do
{
while((pb1->no>pa1->no)&&(pa1->next!=null))
{
pa2=pa1;
pa1=pa1->next;
}
if(pb1->no<=pa1->no)
{
if(ah==pa1)
ah=pb1;
else
pa2->next=pb1;
pb1=pb1->next;
pb2->next=pa1;
pa2=pb2;
pb2=pb1;
}
}while((pa1->next!=null)||(pa1==null&&pb1!=null));
if((pb1!=null)&&(pb1->no>pa1->no)&&(pa1->next==null))
pa1->next=pb1;
return (ah);
}