关于链表排序中节点的交换问题
alist *sortallinfo(alist *head){
alist *p1=NULL,*p2=NULL,*px=NULL,*py=NULL,*p0=NULL;
for (px=head;px!=NULL;px=px->next)
for (py=px;py!=NULL;py=py->next)
{
p1=py;
p2=p1->next;
if (strcmp(p1->name,p2->name)>0)
{
if (p1!=head)
{
p1->next=p2->next;
p0->next=p2;
p2->next=p1;
}
else
{
p1->next=p2->next;
p2->next=p1;
head=p2;
}
}
p0=p1;
}
printf("排序成功,请查看!\n");
return head;
}这段代码有问题么?