为什么 单链表中多项式相加的C语言源程序出错
# include <stdio.h># include <stdlib.h>
typedef struct LNode{
int xp;
int e;
struct LNode * next;
}LinkList;
LinkList * CreateList_L(int n)
{LinkList *L,*p,*q;
L=q=(LinkList *)malloc(sizeof (LinkList));
L->next=NULL;
for(;n>0;n--)
{
p=(LinkList *)malloc(sizeof (LinkList));
scanf("%d %d",&p->xp,&p->e);
p->next=q->next;
q->next=p;
q=p;
}
return L->next;
}
void main()
{
LinkList *La,*Lb,*Lc,*pa,*pb,*pc;
int m=5,n=3;
pa=La=CreateList_L(5);
pb=Lb=CreateList_L(3);
Lc=pc=(La->e<=Lb->e)?La:Lb;
while(pa&&pb)
{
if(pa->e=pb->e)
{pc->e=pa->e;pc->xp=pa->xp+pb->xp;pa=pa->next;pc->next=pa;pb=pb->next;}
else if(pa->e<pb->e)
{pc->e=pa->e;pc->xp=pa->xp;pa=pa->next;pc->next=pa;}
else
{pc->e=pb->e;pc->xp=pb->xp;pb=pb->next;pc->next=pb;}
}
while(Lc)
{printf("%dx^%d+",Lc->xp,Lc->e);
Lc=Lc->next;
}
while(La!=NULL)
{printf("%dx^%d+",La->xp,La->e);
La=La->next;
}
printf("\n");
Lb=CreateList_L(3);
while(Lb!=NULL)
{printf("%dx^%d+",Lb->xp,Lb->e);
Lb=Lb->next;
}
printf("\n");
}