一道数据结构的题目,十万火急高分悬赏.要快啊.

来源:百度知道 编辑:UC知道 时间:2024/06/25 05:36:23
考核说明:
1. 按要求完成实验考核报告,实验考核报告模板已附后;
2. 将该实验考核报告命名为“学号姓名.DOC”,如“07142001张三.DOC”,递交到ftp://10.132.254.1:3333/ 07计本 文件夹中

考核题目:
若多项式用带头结点的链表表示,下面程序为求多项式的导数多项式和多项式的值,请补充完成其中的两个函数,并按要求递交实验考核报告。 (数据自拟,多项式的项按指数递增输入)

已有的部分源程序如下:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define NULL 0
typedef struct Polynode
{
float coef;
int exp;
struct Polynode *next;
}Polynode, *Polylist;
void InitPoly(Polylist *P)
{/*初始化,建立只有头结点的空链表(多项式)*/
Polynode *s;
s=(Polynode*)malloc(sizeof(Polynode)); /*申请新的结点*/
s->next=NULL;
*P=s;
}
void CreatePoly(Polylist P)
{/*依次输入多项式的项,建立多项式,直到输入的系数为0为止*/
Polynode *tail, *s;
float c;
int e;
tail=P; /* tail 始终指向单链表的尾,便于尾插法建表*/
scanf("%f,%d",&c,&e); /*键入多项式的系数和指数项*/
while(c!=0.

这么简单的题目自己想想不就出来了

一句话,链表遍历~~

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define NULL 0
typedef struct Polynode
{
float coef;
int exp;
struct Polynode *next;
}Polynode, *Polylist;
void InitPoly(Polylist *P)
{/*初始化,建立只有头结点的空链表(多项式)*/
Polynode *s;
s=(Polynode*)malloc(sizeof(Polynode)); /*申请新的结点*/
s->next=NULL;
*P=s;
}
void CreatePoly(Polylist P)
{/*依次输入多项式的项,建立多项式,直到输入的系数为0为止*/
Polynode *tail, *s;
float c;
int e;
tail=P; /* tail 始终指向单链表的尾,便于尾插法建表*/
scanf("%f,%d",&c,&e); /*键入多项式的系数和指数项*/
while(c!=0.0) /*若c=0.0,则代表多项式的输入结束*/
{
s=(Polynode*)malloc(sizeof(Polynode)); /*申请新的结点*/
s->coef=c;
s->exp=e;
s->next=NULL;
tail->next=s; /*在当前表尾做插入*/
tail=s;
scanf("%f,%d",&c,&e);
}
}

void PrintPoly(P