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