大家帮我看一下这程序哪错了
#include
#include
typedef struct node
{
int data;
struct node *next;
}slink;
slink *initlist()
{
slink *s0,*p,*s;
int i,a,n;
s=(slink*)malloc(sizeof(slink));
s->next=NULL;
s0=s;
cout<<"链表长度:";
cin>>n;
for (i=1;i<=n;i++)
{
cin>>a;
p=(slink*)malloc(sizeof(slink));
p->data=a;
s0->next=p;
s0=p;
}
p->next=NULL;
return s;
}
slink *position(slink *&c,slink *&d)
{
slink *p=c->next,*q=d->next,*n=d,*m=NULL;
while (p!=NULL&&q!=NULL)
{
if (p->data
{
m=p->next;
p->next=q;
n->next=p;
p=m;
n=q;
}
else if (p->data==q->data)
{
p=p->next;
n=q;
q=q->next;
}
else if (p->data>q->data && p->data
{
m=p->next;
p->next=q->next;
q->next=p;
n=p;
p=m;
q=q->next;
}
}
if (p!=NULL)
{
while (p!=NULL)
{
q->next=p;
p=p->next;
}
}
return d;
}
void displist(slink *b)
{
slink *p;
p=b->next;
while (p!=NULL)
{
cout<
p=p->next;
}
cout<
main()
{
slink *a,*b;
a=initlist();
b=initlist();
b=position(a,b);
displist(b);
}
#include
#include
typedef int ElemType;
typedef struct node
{ElemType data;
struct node *next;
}SLink;
void createlistf(SLink *&sl)
{int i,n,fs;
SLink *s,*r;
sl=(SLink *)malloc(sizeof(SLink));
r=sl;
cout<<"节点个数:";
cin>>n;
for(i=0;i
cout<<"第"<cin>>fs;
s->data=fs;
r->next=s;
r=s;
}
r->next=NULL;
}
SLink *connect(SLink *ha,SLink *hb)
{SLink *pa=ha->next,*pb=hb->next,*tc=hb;
while(pa!=NULL && pb!=NULL)
{if(pa->data
{tc->next=pa;
tc=pa;
pa=pa->next;}
else if(pa->data>pb->data)
{tc->next=pb;
tc=pb;
pb=pb->next;}
else
{tc->next=pb;
tc=pb;
pa=pa->next;
pb=pb->next;
}
}
if(pa!=NULL) tc->next=pa;
if(pb!=NULL) tc->next=pb;
return hb;
}
void shuchu(SLink *sl)
{SLink *p=sl->next;
while(p!=NULL)
{cout<
p=p->next;}
cout<
}
void main()
{SLink *ha,*hb;
createlistf(ha);
createlistf(hb);
*connect(ha,hb);
shuchu(hb);
}