ImageVerifierCode 换一换
格式:DOCX , 页数:25 ,大小:147.35KB ,
资源ID:356904      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/356904.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(一元多项式的加减求导运算算法数据结构算法.docx)为本站会员(b****1)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

一元多项式的加减求导运算算法数据结构算法.docx

1、一元多项式的加减求导运算算法数据结构算法实验题目:一元多项式运算班级:13级数学一班 姓名: 张保昌 学号:2013433037 日期:20141009一、需求分析1问题描述;设计一个简单的一元稀疏多项式加减及求导运算器。2基本要求的功能要求; (1)输入多项式时可以按任意次序输入各项的数据(输入并建立多项式A与B),不必按指数有序;在算法中实现建立按指数有序的多项式。 (2)计算多项式A与B的和,即建立多项式A+B。 (3)按照指数升序次序,输出多项式A、B、A+B。 (4)计算多项式A与B的差,即建立多项式AB; (5) 计算多项式A的导函数A 。3测试数据。 (1)(x+3x68.6x1

2、1)+(63x6+21x9)=6+x+21x98.6x11 (2)(3x3x+4.1x21.2x9)(3x35.1x2 +7.8x12)=xx21.2x9+7.8x12 (3)(x+x3)+(xx3)=0 (4)(x+x2+x3)+0=x+x2+x3 (5)(x+x2+x3)(x+x2+x3)=0 (6) (x+x2+x3)=1+2x+3x2二、概要设计1本程序所用的抽象数据类型的定义;typedef struct pnode double coef; /*系数域*/int exp; /*指数域*/struct pnode *next; /*指针域,*/polynode, *polylink;

3、polylink insert_list(polylink h,char o); /输入多项式。polylink order_list(polylink h); /按指数升序排列polylink simply_list(polylink h); /初步整理(合并多项式,并删除系数为零的式子)polylink add(polylink a,polylink b); /加法运算polylink opposite(polylink b); /将减法统归为加法polylink derivative(polylink a); /求导函数void list_display(polylink h,char

4、o); /输出显示void index(); /菜单函数2模块划分。 1)主函数模块。2)加法运算模块 3)减法运算模块 4)导数模块。3主模块的流程及各子模块的主要功能; 三、详细设计1采用c+语言定义相关的数据类型;typedef struct pnode double coef; /*系数域*/int exp; /*指数域*/struct pnode *next; /*指针域polynode, *polylink;Coef系数域Exp指数域*next指针域2写出各模块的伪码算法;void index() /菜单函数。 cout 一元多项式运算 endlendl; cout 1.一元多项式

5、加法endl; cout 2.一元多项式减法endl; cout 3.一元多项式导数endl; cout 0. 结束 endlendlnext =NULL;/头结点 cout多项式onum; for(int i=1;i=num;i+) cout请输入第i项endl; coutcoef1; coutexpo1; data=new polynode; data-coef=coef1; data-exp =expo1; data-next =NULL; temp-next =data; temp=data; return h;polylink simply_list(polylink h) /初步化

6、简,系数无0,无重复指数 polylink p,q,r,k; p=h-next ; if(!p) return h; /空表 while(p) k=p; q=k-next ; while(q) if(q-exp=p-exp ) r=q; q=q-next ; p-coef +=r-coef ; k-next =r-next ; delete r; else q=q-next ; k=k-next; p=p-next ; k=h; q=h-next ; while(q) if( q -coef=0) r=q; q=q-next ; k-next =r-next ; delete r; else

7、q=q-next ; k=k-next ; return h;void list_display(polylink h,char o) /显示多项式 polylink p; double coef1; int expo1,i=0; p=h-next ; if(!p) cout多项式o : 0 endl; else cout多项式ocoef ; expo1=p-exp ; if(i=0) if(expo1=0) i=1; coutcoef1; else if(expo1=1) i=1; if(coef1=1) coutX; else if(coef1=-1) cout-X; else coutc

8、oef1X; else i=1; if(coef1=1) coutXexpo1; else if(coef1=-1) cout-Xexpo1; else coutcoef1Xexpo1; else if(expo1=1) if(coef1=1) cout+X; else if(coef1=-1) cout0) cout+coef1X; else coutcoef1X; else if(coef1=-1) cout-Xexpo1; else if(coef1=1) cout+X0) cout+coef1Xexpo1; else coutcoef1Xnext ; coutnext; if(!p)r

9、eturn h; while(p-next) q=p-next ; r=p; while(q) if(q-exp exp ) r=q; q=q-next ; temp.coef =r-coef ; temp.exp =r-exp ; r-coef =p-coef ; r-exp =p-exp ; p-coef =temp.coef ; p-exp =temp.exp ; p=p-next ; return h;polylink add(polylink ha,polylink hb)/加法 polylink a; a=ha; while(a-next ) a=a-next ; a-next =

10、hb-next ; delete hb; ha=simply_list(ha); ha=order_list(ha); return ha;polylink opposite(polylink b) polylink hb; hb=b-next; while(hb) hb-coef =(-1)*hb-coef; hb=hb-next ; return b;polylink derivative(polylink a)/求导 polylink ha; ha=a-next ; while(ha) ha-coef *=ha-exp ; ha-exp -; ha=ha-next ; return a;

11、 四、调试分析1调试中遇到的问题及对问题的解决方法; 指针指向的错误。导致程序无法正常运行,经过逐步调试,发现了问题,认真分析指针指向的内存空间。并做了合理的修改。2算法的时间复杂度和空间复杂度。 polylink order_list(polylink h); O(n) polylink simply_list(polylink h); O(n) polylink add(polylink a,polylink b); O(n) polylink opposite(polylink b);/ O(n) polylink insert_list(polylink h,char o) O(n) polylink derivative(polylink a); /O(n) void list_display(polylink h,char o); O(

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1