SHARE
TWEET

Untitled

a guest Nov 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double Horner(int n, double a[], double x)
  6. {
  7.     double w=a[0];
  8.     for(int i=1;i<=n;i++)
  9.     {
  10.         w=w*x+a[i];
  11.     }
  12.     return w;
  13. }
  14.  
  15. void HornerUnormowany(int n, double a[], double x)
  16. {
  17.     for(int j=0;j<n;j++)
  18.     {
  19.         for(int i=1;i<=n-j;i++)
  20.         {
  21.             a[i]=a[i-1]*x+a[i];
  22.         }
  23.     }
  24. }
  25.  
  26. void pochodna(int n, double a[])
  27. {
  28.     int rob=1;
  29.     for(int i=n;i>=0;i--)
  30.     {
  31.         a[i]=a[i]*rob;
  32.         rob=rob*(n-i+1);
  33.     }
  34. }
  35.  
  36. void wyswietl(int n, double a[])
  37. {
  38.     for(int i=n;i>=0;i--)
  39.     {
  40.         cout<<a[i]<<" ";
  41.     }
  42.     cout<<endl;
  43. }
  44.  
  45. int main()
  46. {
  47.     double a[]={1,0,0,-2,0,0,-1,2}; // wektor ktory przechowuje wartosci wspolczynnikow przy kolejnych potegach wielomianu
  48.     int n=7; // stopien wielominu
  49.     double x=2; //liczba przez ktora dzielimy wielomian
  50.     //cout<<Horner(n,a,x)<<endl;
  51.     HornerUnormowany(n,a,x);
  52.     wyswietl(n,a);
  53.     pochodna(n,a);
  54.     wyswietl(n,a);
  55.     return 0;
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top