链表排序,大哥帮看那错了
struct student *merge(struct student *connect){
struct student *pa1,*pa2,*pa3,*pa,*head;
pa2=pa1=connect;
head=pa=NULL;
while(pa1->join!=NULL)
{
pa2=connect;
while(pa2->join!=NULL)
{
if(pa==NULL)
{
if(pa2->number<pa3->number)pa3=pa2;
}
else if(pa2->number>pa->number)
{
if(pa3==pa)pa3=pa2;
else if(pa2->number<pa3->number)pa3=pa2;
}
pa2=pa2->join;
}
if(head==NULL&&pa==NULL)head=pa=pa3;
else {pa->join=pa3;
pa=pa->join;
}
pa1=pa1->join;
}
return(head);
}
链表这样排序不行吗,怎么循环到后面,有几个数都没了。我是想把最小的数插到新链表去,我没动旧链表啊?