代码:
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 100
#define OK 1
#define ERROR -1
typedef int Status;
typedef int Elemtype;
typedef struct polynomail{
float coef; //系数
int expt ; //指数
}Polynomail;
typedef struct sqList{
Polynomail *arr;
int length;
}SqList;
//顺序表初始化
Status Init_SqList(SqList *L){
L->arr = (Polynomail*)malloc(MAX_SIZE*sizeof(Polynomail));
if(!L->arr)
return ERROR;
L->length = 0;
return OK;
}
//创建多项式
void Creat_Polynomail(SqList *L){
int i;
int m;
printf("输入多项式的项数:");
scanf("%d", &m);
if(m < 0 || m > MAX_SIZE){
printf("输入不合法");
}
float n = 0.0;
//n1*x0 + n2*X1 + ... + nm*X(m-1)
for(i = 0; i < m; i++){
printf("输入x^%d的系数:", i);
scanf("%f", &n);
L->arr[