fork 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 w = 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 << "x = " << x << endl;
  23. cout << "w(3) = " << w << endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Stopien wielomianu: 3
x = 3
w(3) = 98