网站大量收购独家精品文档,联系QQ:2885784924

数据结构多项式运算的程序(加减法和乘法)C语言版(Data structure polynomial computing procedures (addition and subtraction and multiplication) C Language Edition).doc

数据结构多项式运算的程序(加减法和乘法)C语言版(Data structure polynomial computing procedures (addition and subtraction and multiplication) C Language Edition).doc

  1. 1、本文档共17页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据结构多项式运算的程序(加减法和乘法)C语言版(Data structure polynomial computing procedures (addition and subtraction and multiplication) C Language Edition) # includes stdio.h # includes malloc.h typedef struct node {/ / 定义节点类型 float coef; int expn; struct node * next; } ploy; void start () / / 用户选择界面 { printf (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n); printf (两个一元多项式的相加 / 相减, 相乘: \ n); printf (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n); printf (请选择操作: \ n); printf (0.退出 \ n); printf (1.两个一元多项式相加 \ n); printf (2.两个一元多项式相乘 \ n); printf (3.两个一元多项式相减 \ n); } void insert (ploy * head, * inpt ploy) / / 查找位置插入新链节程序 { ploy * pre, * now. int signal = 0; pre = head; / / pre定义为现在的前一个链节 if (pre - next = = null) (pre - next = inpt;} else {now = pre - next; while (signal = = 0) { if (inpt - expn - now - expn) / / 当新链节小于现在的连接时向后移一个链节 { if (now - next = = null) { now - next = inpt; signal = 1; } else { pre = now. now = pre - next; } } else if (inpt - - now expn 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; printf (请输入一元多项式% c: (格式是: 系数 指数; 以0 0 结束!) \ n, ch); scanf (%% d , x y); while (x! = 0) { inpt = (ploy *) malloc (sizeof (ploy)); / / 创建新链节 inpt - coef = x; inpt - expn = y; inpt - next = null; insert (head, inpt); / / 不然就查找位置并且插入新链节 printf (请输入一元多项式% c的下一项: (以0 0 结束!) \ n, ch); scanf (%% d , x y); } return head; } ploy * addploy (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

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档