设计一种用单链表存储多项式的结构 c语言 在线等答案

来源:百度知道 编辑:UC知道 时间:2024/09/20 11:48:27
题目:设计 一种用单链表存储多项式的结构(每个结点存储一项的系数和指数,类型都为int),并编写一个产生多项式链表的函数的一个实现两个多项式相加和相乘的函数。

写好了,你看看
输入方法:
1 2 1 1 0 0
1 2 1 1 0 0

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

typedef struct polynomial
{
int coef,ex;
struct polynomial *next;
}POLY;

POLY *create_poly(void);

POLY *add_poly(POLY *,POLY *);

POLY *mul_poly(POLY *,POLY *);

void print_poly(POLY *);

int main(void)
{
POLY *heada=NULL,*headb=NULL,*headsum=NULL,*headmul=NULL;
printf("create the first multinomial:\n");
heada=create_poly();
printf("create the second multinomial:\n");
headb=create_poly();
printf("The first multinomial:\n");
print_poly(heada);
printf("The second multinomial:\n");
print_poly(headb);
headsum=add_poly(heada,headb);
printf("The sum multinomial:");
print_poly(headsum);
headmul=mul_poly(heada, head