예제 #1
0
파일: main.cpp 프로젝트: m1zaru/C-Files
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
0
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();*/
}
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
0
파일: Fund.cpp 프로젝트: Tythos/cuben
		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
0
파일: main.cpp 프로젝트: wateryheart/2012a2
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); 
}