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

单链表表示多项式相乘实习报告.doc

  1. 1、本文档共11页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
单链表表示多项式相乘实习报告

实习报告 实习题: 请写出计算两个以单链接表表示的多项式相乘的程序。 设计: 因为进行插入删除时,有头结点的单链表的实现会更方便,所以采用带头结点的单链表,一个单链表代表一个多项式,每个结点代表多项式的一个因子,每个结点都有两个数据和一个指针,数据分别代表每个因子的系数和指数。 (1)存储结构: 结点类: class Listnode { friend class List; friend ostream operator (ostream output,const Listnode node); private: Listnode* next;//point to the next node int coefficient; int exponent; public: Listnode(const int e1,const int e2,Listnode*p=NULL) :coefficient(e1),exponent(e2),next(p){}//constructor with three parameters Listnode() :next(NULL){}//constructor without parameters Listnode* Get(){return next;}//get the next ~Listnode(){}//析构函数 }; 单链表类: class List { friend ostream operator (ostream output,List list); friend istream operator (istream input,List list); private: Listnode* head;//point to the head of the list Listnode* current;//point to the current node public: List(){head = new Listnode();current = head;}//constructor ~List(){Makeempty();delete head;}//析构函数 int Isempty(){return head-next == NULL;}//if the list is empty return 1,else rerurn 0 void First(){current=head-next;}//make current point to the first node void operator ++() { if (current!=NULL) current=current-next; }//make current point to the next node void operator ++(int){operator++();} int Isfull(){}//the list is generally unable to be full void Makeempty();//clear the list int Find(const int x,const int y);//if (x,y) is in the list,return 1 void Insert(const int x,const int y);//insert a node to the list whose element is (x,y),then current point to it void Delete(const int x,const int y);//delete the node whose element is (x,y) const List operator = (const List list);//copy the right list to the left one List operator +(List list);//get the sum of two lists List operator *(List list);//get the multiply of the two lists }; 算法思想: 设多项式A,B,A有m项

文档评论(0)

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

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

1亿VIP精品文档

相关文档