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