本文整理汇总了C++中Polynomial::print方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::print方法的具体用法?C++ Polynomial::print怎么用?C++ Polynomial::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::print方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char * argv[]) {
Polynomial poly;
Polynomial poly2;
Polynomial poly3;
poly.readFromUser();
poly2.readFromUser();
cout << "poly: ";
poly.print();
cout << "poly2: ";
poly2.print();
cout << "poly3 = poly2 + poly: ";
poly3 = poly+poly2;
poly3.print();
cout << "poly2 before being multiplied by 3: ";
poly2.print();
poly2.multyPoly(3);
cout << "after ";
poly2.print();
poly = -poly;
cout << "poly being negated: ";
poly.print();
cout << "poly3's coefficient for 5th degree: " << poly3.coefficient(5) << endl;
poly3.changeCoefficient(10, 5);
cout << "after changing poly3's 5th degree coefficient to 10: " << poly3.coefficient(5) << endl;
cout << "highest degree of poly2: " << poly2.degree() << endl;
return 0;
}
示例2: main
int main()
{
Polynomial p;
p.setA(0,1);
p.setA(1,5);
p.setA(2,0);
p.setA(3,3);
/*p.setA(4,2);
p.setA(5,2);
p.setA(6,0);
p.setA(7,0);*/
p.print();
cout<<endl<<p.deg()<<endl;
Polynomial q;
q.setA(0,0);
q.setA(1,0);
q.setA(2,0);
q.setA(3,0);
/*q.setA(4,0);
q.setA(5,0);
q.setA(6,0);
q.setA(7,0);*/
q.print();
cout<<endl<<q.deg()<<endl;
/*
cout<<endl<<"dodawanie; ";
add(p, q).print();
cout<<endl<<"mnozenie: ";
mult(p, q).print();
cout<<endl<<"wartosc p dla 2; ";
cout<<value(p, 2);
Polynomial wynik;
Polynomial reszta;
div(p, q, wynik, reszta);
cout<<endl<<"DZIELENIE: "<<"wynik: ";
wynik.print();
cout<<" reszta: ";
reszta.print();*/
}
示例3: main
int main(int argc, char const *argv[])
{
Term term1(3,4);
Term term2(3,2);
Term term3(3,3);
Term term4(3,7);
Polynomial poly;
poly.push_back(term1);
poly.push_back(term2);
poly.push_back(term3);
poly.push_back(term4);
poly.print();
poly.differentiate();
poly.print();
return 0;
}
示例4: test
bool test() {
Polynomial p = Polynomial();
p.push(0.0f,0.0f);
p.push(M_PI/6,0.5f);
p.push(2*M_PI/6,0.866f);
p.push(3*M_PI/6,1.0f);
p.print();
/* std::cout << "p(-2.0f) = " << p.eval(-2.0f) << std::endl;
std::cout << "p(0.0f) = " << p.eval(0.0f) << std::endl;
std::cout << "p(1.0f) = " << p.eval(1.0f) << std::endl;
std::cout << "p(2.0f) = " << p.eval(2.0f) << std::endl;
std::cout << "p(4.0f) = " << p.eval(4.0f) << std::endl;*/
return true;
}
示例5: main
int main(void)
{
Polynomial a, b, d;
a.readPoly("input1.txt");
cout << "a=";
a.print();
b.readPoly("input2.txt");
cout << "b=";
b.print();
d=a;
cout << "d=";
d.print();
Polynomial e(b);
cout << "e=";
e.print();
cout << "a(2)=" << a(2) << endl;
if (a==b) cout << "a equals to b." << endl;
else cout << "a does not equal to b." << endl;
cout << "a+b=";
(a+b).print();
cout << "a-b=";
(a-b).print();
cout << "a*b=";
(a*b).print();
cout << "d+=b; d=";
d+=b;
d.print();
cout << "e-=a; e=";
e-=a;
e.print();
cout << "b+=10; b=";
b+=10;
b.print();
cout << "10+b=";
Polynomial temp;
temp=10+b;
temp.print();
cout << "10*b=";
(10*b).print();
cout << "b*10=";
(b*10).print();
cout << "e*=10, e=";
e*=10;
e.print();
return (0);
}