数据结构多项式的加减(方法01).txt爱情是艺术,结婚是技术,离婚是算术。这年头女孩们都在争做小“腰”精,谁还稀罕小“腹”婆呀?高职不如高薪,高薪不如高寿,高寿不如高兴。#include #include typedef struct node //定义节点类型 {float coef; int expn; struct node * next; }PLOY; void insert(PLOY *head,PLOY *inpt) //查找位置插入新链节程序 { PLOY *pre,*now; int signal=0; pre=head; if(pre->next==NULL) {pre->next=inpt;} else {now=pre->next; while(signal==0) { if(inpt->expnexpn) { if(now->next==NULL) { now->next=inpt; signal=1; } else { pre=now; now=pre->next; } } else if(inpt->expn>now->expn) { inpt->next=now; pre->next=inpt; signal=1; } else { now->coef=now->coef+inpt->coef; signal=1; free(inpt); if(now->coef==0) { pre->next=now->next; free(now); } } } } } PLOY *creat(char ch) //输入多项式 { PLOY *head,*inpt; float x; int y; head=(PLOY *)malloc(sizeof(PLOY)); //创建链表头 head->next=NULL; scanf("%f %d",&x,&y); while(x!=0) { inpt=(PLOY *)malloc(sizeof(PLOY)); //创建新链节 inpt->coef=x; inpt->expn=y; inpt->next=NULL; insert(head,inpt); //查找位置并且插入新链节 scanf("%f %d",&x,&y); } return head; } PLOY *add(PLOY *head,PLOY *pre) //多项式相加 { PLOY *inpt; int flag=0; while(flag==0) { if(pre->next==NULL) flag=1; //跳出循环 else { pre=pre->next; inpt=(PLOY *)malloc(sizeof(PLOY)); inpt->coef=pre->coef; inpt->expn=pre->expn; inpt->next=NULL; insert(head,inpt); // 把当前“g(x)”的链节插入到“y(x)”中 } } return head; } PLOY *sub(PLOY *head,PLOY *pre) //多项式相减 { PLOY *inpt; int flag=0; while(flag==0) { if(pre->next==NULL) flag=1; else { pre=pre->next; inpt=(PLOY *)malloc(sizeof(PLOY)); inpt->coef=0-pre->coef; inpt->expn=pre->expn; inpt->next=NULL; insert(head,inpt); } } return head; } void print(PLOY *fun) //输出多项式 { PLOY *printing; int flag=0; printing=fun->next; if(fun->next==NULL) { ...