fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. double x;
  7. double a[4] = {4, 0, 0, 1}; // a0, a1, a2, a3
  8. double wynik = 0;
  9.  
  10. cout << "Podaj wartosc x: ";
  11. cin >> x;
  12.  
  13. // algorytm naiwny
  14. for (int i = 0; i <= 3; i++) {
  15. wynik += a[i] * pow(x, i);
  16. }
  17.  
  18. cout << "Wartosc wielomianu: " << wynik << endl;
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Podaj wartosc x: Wartosc wielomianu: 4