一个链表排序函数 看下哪错了
struct adlist*sort(struct adlist*head)//排序 { //struct adlist*head;
struct adlist*q,*p,*temp,*p1,*p2;
struct adlist*head1;
int n=0;
head1=NULL;
p1=p2=(struct adlist*) malloc(LEN);
for(q=head->next;q->next!=NULL;q=q->next)
{ temp=q;
for(p=q;p->next!=NULL;p=p->next)
{ if(strcmp(temp->QQ,p->QQ)>0)
{ temp=p;}
}
p1=temp;
n=n+1;
if(n==1) head1=p1;
else p2->next=p1;
p2=p1;
p1=(struct adlist*)malloc(LEN);
}
p2->next=NULL;
return(head1);
}