Facebook
From Fiery Plover, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 149
  1. #include <iostream>
  2. using namespace std;
  3. double oblicz (double A[], int n, double x)
  4. {
  5.     double w=A[0];
  6.     for (int i=1; i<=n; i++)
  7.     w=w*x+A[i];
  8.     return w;
  9. }
  10. int main()
  11. {
  12.     double A[4];
  13.     int n;
  14.     double x;
  15.     cout<<"podaj x:"<<endl;
  16.     cin>>x;
  17.     cout<<"podaj n:"<<endl;
  18.     cin>>n;
  19.     cout<<"podaj nastpene wspolczynniki wielomianu:"<<endl;
  20.     for(int i=0; i<=n; i++)
  21.     {
  22.         cout<<"A["<<i+1<<"]=";
  23.         cin>>A[i];
  24.     }
  25.     cout<<"wynik= "<<oblicz(A,n,x);
  26.     return 0;
  27. }
  28.