C语言的一元多项式相乘问题,高手救急!

来源:百度知道 编辑:UC知道 时间:2024/06/05 03:15:29
编写C语言的程序如下,实现两个多项式的相乘,但是乘不出结果,这是为什么?完整程序如下:

#include<stdio.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct term)
struct term
{int coef;
int expo;
struct term *next;
};
int m;

struct term *CreatPolyn(void)//创建表
{struct term *head1;
struct term *p1,*p2;
m=0;
p1=p2=(struct term*)malloc(LEN);
scanf("%d %d",&p1->coef,&p1->expo);
head1=NULL;
while(p1->coef!=0)
{m=m+1;
if(m==1)head1=p1;
else p2->next=p1;
p2=p1;
p1=(struct term*)malloc(LEN);
scanf("%d %d",&p1->coef,&p1->expo);
}
p2->next=NULL;
return(head1);
}

struct term *PrintPolyn(struct term *head)//输出多项式
{struct term *p;
printf("\nNow,the polynomial is:\n",m);
p=head;
if(head!=NULL)
{for(;p!=NULL;)
{
if(p->expo!=0&&p->coef!=0)
printf("%dX^%d&qu

发给你了~~~

#include "stdio.h"
#include "alloc.h"
#include "conio.h"
typedef struct node
{ int e,c;
struct node *next;
}PN;
PN *createLink()
{ int n;
PN *head, *p;
p=head=(PN*)malloc(sizeof(PN));
printf("n=");
scanf("%d",&n);
while(n)
{ p->next=(PN*)(PN*)malloc(sizeof(PN));
p=p->next;
printf("c,e:");
scanf("%d%d",&p->c,&p->e);
n--;
}
p->next=NULL;
return head;
}
void printLink(PN *h)
{ PN *p=h->next;
while(p)
{ printf("(%d,%d) ", p->c, p->e);
p=p->next;
}
printf("\n");
}
void freeLink(PN *h)
{ PN *p=h;
while(p)
{ h=h->next;
free(p);
p=h;
}
}
PN *add(PN *ha, PN *hb)
{ PN *hc,*pc,*pa=ha->next,*pb=hb-&