fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int stopien = 3;
  9. double a3 = 2;
  10. double a2 = 3;
  11. double a1 = 4;
  12. double a0 = 5;
  13. double x = 3;
  14.  
  15. // algorytm naiwny
  16. double wynik = a3 * pow(x, 3)
  17. + a2 * pow(x, 2)
  18. + a1 * pow(x, 1)
  19. + a0 * pow(x, 0);
  20.  
  21. cout << "stopien wielomianu: " << stopien << endl;
  22. cout << "a3 = " << a3 << endl;
  23. cout << "a2 = " << a2 << endl;
  24. cout << "a1 = " << a1 << endl;
  25. cout << "a0 = " << a0 << endl;
  26. cout << "x = " << x << endl;
  27. cout << "w(3) = " << wynik << endl;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
stopien wielomianu: 3
a3 = 2
a2 = 3
a1 = 4
a0 = 5
x = 3
w(3) = 98