fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. // Dane wielomianu
  8. int stopien = 3;
  9.  
  10. int a3 = 2;
  11. int a2 = 3;
  12. int a1 = 4;
  13. int a0 = 5;
  14.  
  15. int x = 3;
  16.  
  17. // Wyƛwietlanie danych
  18. cout << "Stopien wielomianu: " << stopien << endl;
  19. cout << "Wspolczynniki:" << endl;
  20. cout << "a3 = " << a3 << endl;
  21. cout << "a2 = " << a2 << endl;
  22. cout << "a1 = " << a1 << endl;
  23. cout << "a0 = " << a0 << endl;
  24. cout << "x = " << x << endl << endl;
  25.  
  26. // Algorytm naiwny
  27. int W = a3 * pow(x, 3)
  28. + a2 * pow(x, 2)
  29. + a1 * x
  30. + a0;
  31.  
  32. // Wynik
  33. cout << "W(" << x << ") = " << W << endl;
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Stopien wielomianu: 3
Wspolczynniki:
a3 = 2
a2 = 3
a1 = 4
a0 = 5
x = 3

W(3) = 98