麻烦各位大侠帮我看一下,这个老是出现内存引用问题,以下的为单链表的:创建、合并、排序、等问题。我是个初学者,希望大侠们帮我指点一下,谢谢!


#include<stdio.h>
#include<stdlib.h>



typedef int datatype;
typedef struct link_node{
datatype info;
struct link_node *next;
}node;




node *init()
{
return NULL;
}





void display(node *head)
{
node *p;
p=head;
if(!p)
printf("\n单链表是空的");
else
{
printf("\n单链表的各结点的值为:");
printf("\n");
while(p) {printf("%5d",p->info);p=p->next;}
printf("\n");
}
}





node *find(node *head,int i)
{
int j=1;
node *p=head;
if(i<1) return NULL;
while(p&&i!=j)
{
p=p->next;j++;
}
return p;
}





node *insert(node *head,datatype x,int i)
{
node *p,*q;
q=find(head,i);
if(!q&&i!=0)
printf("\n找不到第%d个结点,不能插入%d",i,x);
else
{
p=(node*)malloc(sizeof(node));
p->info=x;
if(i==0)
{
p->next=head;
head=p;
}
else
{
p->next=q->next;
q->next=p;
}
}
return head;
}






node *creat(node *head)
{
int i=0,n,x;
printf("input the size of lianbiao\n");
scanf("%d",&n);
printf("\n  input the number one bay one\n");
for(i=0;i<n;i++)
{
    scanf("%d",&x);
    head=insert(head,x,i);
    
}
return head;
}




node *dele(node *head,datatype x)
{
node *pre=NULL,*p;
if(!head)
{printf("\n单链表是空的");return head;}
p=head;
while(p&&p->info!=x)
{pre=p;p=p->next;}
if(p)
{
if(!pre)  head=head->next;
else pre->next=p->next;
free(p);
}
return head;
}





node *findhou(node *head)
{
node *p;
if(!head)
p=NULL;
else
{
p=head;
while(p->next)
p=p->next;
}
return p;
}




int jishu(node *head)
{
int k=0;
node *p=head;
while(p)
{k=1;p=p->next;k++;}

return k;

}





node *houcha(node *head,node *p)
{
node *q;
if(head)
{
    q=findhou(head);
    q->next=p->next;
    q->next=p;
    

}
else
head=p;
return head;

}






node *paixu(node *head)
{
node *p,*q,*min,*nhead;
p=head;
q=p->next;
min=p;
nhead=NULL;
if(head)
while(p->next)
{
    while(q)
{
    if(q->info<min->info)
    min=q;
    q=q->next;
}
    nhead=houcha(nhead,min);
    head=dele(head,min->info);



    p=head;
    min=p;
    q=p->next;



}

return nhead;

}






node *hebing(node *head1,node *head2)/*两个链表的合并函数*/
{
node *p=head1,*q=head2;
while(p)
{
while(q)
{ if(p->info==q->info) head2=dele(head2,q->info); q=q->next; }
p=p->next;
}
p->next=head2;
return head1;
}





node *daoxu(node *head)/*链表的倒置函数*/
{
node *p,*q,*r;
p=head;
q=p->next;
r=q->next;
p->next=NULL;

while(r)
{
q->next=p;
p=q;
q=r;
r=r->next;
}

r->next=q;
head=r;
return head;
}




void main()
{
node *h,*pre,*r;
int n,i;
h=init();
h=creat(h);
display(h);
pre=findhou(h);
printf("%d",pre->info);
printf("\n");
printf("input the size of number");
scanf("%d",&n);
for(i=0;i<n;i++)
{
r=(node*)malloc(sizeof(node));
scanf("%d",&r->info);
h=houcha(h,r);
}
display(h);

}[em80][em80][em80]