91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 134KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-06-19
  • 語言: C/C++
  • 標簽:

資源簡介

(數(shù)據(jù)結(jié)構(gòu))用鏈表結(jié)構(gòu)(C++)實現(xiàn)多項式的加法和乘法運算。

資源截圖

代碼片段和文件信息

#include

class?Term
{
private:
int?coef;
int?exp;
Term?*link;
public:
Term(int?cint?e);
Term(int?cint?eTerm?*nxt);
Term?*InsertAfter(int?cint?e);
friend?ostream?&?operator<<(ostream?&const?Term?&);
friend?class?Polynominal;
};

Term::Term(int?cint?e):coef(c)exp(e)
{
link=0;
}

Term::Term(int?cint?eTerm?*nxt):coef(c)exp(e)
{
link=nxt;
}

Term?*Term::InsertAfter(int?cint?e)
{
link=new?Term(celink);
return?link;
}

ostream?&?operator<<(ostream?&outconst?Term?&val)
{
out< switch(val.exp)
{
case?0:break;
case?1:out<<“X“;
break;
default:out<<“X^“< break;
}
return?out;
}


class?Polynominal
{
private:
Term?*theList;
public:
Polynominal();
~Polynominal();
void?AddTerms(istream?&in);
void?Output(ostream?&out)?const;
void?PolyAdd(Polynominal?&r);
void?PolyMul?(Polynominal?&r);
friend?ostream?&operator<<(ostream?&const?Polynominal?&);
friend?istream?&operator>>(istream?&const?Polynominal?&);
friend?Polynominal?&operator?+(Polynominal?&Polynominal?&);
friend?Polynominal?&operator?*(Polynominal?&Polynominal?&);
};

Polynominal::Polynominal()
{
theList=new?Term(0-1);
theList->link=theList;
}

Polynominal::~Polynominal()
{
Term?*p=theList->link;
while(p!=theList)
{
theList->link=p->link;
delete?p;
p=theList->link;
}
delete?theList;
}

void?Polynominal::AddTerms(istream?&in)
{
Term?*q=theList;
int?ce;
for(;;)
{
cout<<“Input?a?trem(coefexp):\n“< cin>>c>>e;
if(e<0)
break;
q=q->InsertAfter(ce);

}
}

void?Polynominal::Output(ostream?&out)?const
{
int?first=1;
Term?*p=theList->link;
cout<<“The?polynominal?is:\n“< for(;p!=theList;p=p->link)
{
if(!first&&(p->coef>0))
out<<“+“;
first=0;
out<<*p;
}
cout<<“\n“<}

void?Polynominal::PolyAdd(Polynominal?&r)
{
Term?*q*q1=theList*p;
p=r.theList->link;
q=q1->link;
while(p->exp>=0)
{
while(p->expexp)
{
q1=q;
q=q->link;
}
if(p->exp==q->exp)
{
q->coef=q->coef+p->coef;
if(q->coef==0)
{
q1->link=q->link;
delete?(q);
q=q1->link;
}
else
{
q1=q;
q=q->link;
}
}
else
q1=q1->InsertAfter(p->coefp->exp);
p=p->link;
}
}

void?Polynominal::PolyMul(Polynominal?&r)
{
????Term?*p*q*m*n*s;
????int?c=0e=0;
????p=r.theList->link;
????q=theList->link;
????m=new?Term(0-1);
????m->link=m;
????n=m;
s=n->link;
????while(q->exp>=0)
????{
????????p=r.theList->link;
????????while(p->exp>=0)
????????{
????????????c=q->coef*p->coef;
????????????e=q->exp+p->exp;
while(s->exp>=0&&s->exp>e)
{
n=s;
s=s->link;
}
if(s->exp==e)
{
s->coef=s->coef+c;
if(s->coef==0)
{
n->link=s->link;
delete?s;
}
}
else
n->InsertAfter(ce);
????
n=m;
s=n->link;
????????????p=p->link;
????????}
????????q

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????I.A....????213089??2010-03-27?22:48??多項式的算術(shù)運算\Debug\Polynominal.exe

????I.A....?????19935??2010-03-27?22:48??多項式的算術(shù)運算\Debug\Polynominal.obj

????I.A....????549888??2010-03-27?22:48??多項式的算術(shù)運算\Debug\Polynominal.pdb

????I.A....?????61440??2010-03-27?22:48??多項式的算術(shù)運算\Debug\vc60.pdb

????I.A....??????3514??2010-03-24?20:33??多項式的算術(shù)運算\Polynominal.cpp

????I.A....??????3461??2010-03-24?20:14??多項式的算術(shù)運算\Polynominal.dsp

????I.A....???????547??2010-03-24?20:50??多項式的算術(shù)運算\Polynominal.dsw

????I.A....?????50176??2010-03-27?22:49??多項式的算術(shù)運算\Polynominal.ncb

????I.A....?????48640??2010-03-27?22:49??多項式的算術(shù)運算\Polynominal.opt

????I.A....???????777??2010-03-27?22:49??多項式的算術(shù)運算\Polynominal.plg

????I..D...?????????0??2010-08-11?14:30??多項式的算術(shù)運算\Debug

????I..D...?????????0??2010-08-11?14:30??多項式的算術(shù)運算

-----------?---------??----------?-----??----

???????????????951467????????????????????12


評論

共有 條評論