vertc

30-05

May 30th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. double i,n;
  8. int wartosc[100];
  9. double x;
  10.  
  11. int licz(int i) {
  12.     if (i == 0)
  13.         return wartosc[0];
  14.     else
  15.         return licz(i-1) * x + wartosc[i];
  16.     }
  17.    
  18. int main() {
  19.     cout<<"Podaj stopien wielomianiu: "<<endl;
  20.     cin>>n;
  21.     cout<<"Podaj wartosci a:"<<endl;
  22.     for (int i=0;i<=n;i++) {
  23.         cout<<"a("<<i<<") = ";
  24.         cin>>wartosc[i];
  25.     }
  26.    
  27.     cout<<endl<<"Podaj x: ";
  28.     cin>>x;
  29.     cout<<endl<<"Wynik to: "<<licz(n);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment