Develop a C++ class Polynomial to represent and manipulate univariate polynomials with integer coefficients use circular linked lists with header nodes). Each term of the polynomial will be represented as a node.Thus,a node in this system will have three data members s below:

[ coef | exp | link ]

Each polynomial is to be reprsented as a circular list with header node.To delete polynomials efficiently,we need to use an available-space list and associated functions as described in Section 4.5.The extrnal(i.e,for input or output)representation of a univariate polynomial will be assumed to be a sequence of integers of the from:n,c1,e1,c2,e2,c3,e3,...cn,en,where ei represents an exponents are in decreasing order-e1>e2>...>en.

Write and test the following functions:

(a) istream& operator>>(istream& is,Polynomial& x):
      Read in an input polynomial and convert it to its circular representation using a header node.

(b) ostream& operator<<(ostream& os,Polynomial& x):
     Convert x from its linked list representation to its external representation and output it.

(c) const Polynomial::Polynomial(const Polynomial& a)[Copy Constructor]:
     Initialize the polynomial *this to the polynomial a.

(d)const Polynomial& Polynomial::operator=(const Polynomial&a)const[Assignment Operator]:
     Assign polynomial a to *this.

(e)Polynomial::~polynomial()[Destructor]:
     Return all nodes of the polynomial *this to the available-space list.

(f)Polynomial operator+ (const Polynomial& b) const [Addition]:
    Create and return the polynomial *this +b.

(g)Polynomial operator- (const Polynomial& b) const [Subtraction]:
    Create and return the polynomial *this -b.

(h)Polynomial operator* (const Polynomial& b) const [Multiplcation]:
    Create and return the polynomial *this *b.

(i)float Polynomial::Evaluate(float x)const:
   Evaculate the polynomial *this at x and return the result

距離作業交件還有4天
頭爆痛的...

文章標籤
全站熱搜
創作者介紹
創作者 tabrislin 的頭像
tabrislin

METEOR13

tabrislin 發表在 痞客邦 留言(1) 人氣(220)