数据结构实验-线性表及其的基本操作
实验内容:
1.定义一个一元多项式结构,完成一元多项式的建立,加法和减法以及输出算法的实现。
2.选作:完成一元多项式的乘法操作。
代码:
#include<stdio.h>
#include<stdlib.h>
typedef struct NODE
{
int coef; ///系数
int exp; ///指数
struct NODE *next;
}polynode,*Polylist;
int output_list(Polylist head);
Polylist Creat_list()
{ ///创建链表
Polylist head,rear,s;
head = (Polylist)malloc(sizeof(polynode));
rear = head;
while(1)
{
printf(“input the coef,exp:\n”);
s = (Polylist)malloc(sizeof(polynode));
scanf("%d", &s->coef);
if(!s->coef)
{
free(s);
break;
}
scanf("%d", &s->exp);
rear->next = s;
rear = s;
}
rear->next = NULL;
return (head);
}
Polylist add_list(Polylist head1,Polylist hea