Advertisement
sellmmaahh

z11-pocetak

Mar 2nd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. double S(double x, int n);
  5.  
  6. int main ()
  7. {
  8.     double x;
  9.     int n;
  10.     std::cout<<"Unesite x: ";
  11.     std::cin>>x;
  12.     std::cout<<std::exp(x);
  13.     double a=S(x,n);
  14.     while (std::fabs(S(x,n)-std::exp(x))>=0.00001)
  15.      {
  16.  
  17.        n++; }
  18.     std::cout<<n;
  19.     return 0; }
  20.  
  21. double S(double x, int n)
  22. { double s=x;
  23. int k(1);
  24.     for ( k=0; k<=n; k++)
  25.     { s*=x;
  26.     k*=k;
  27.  
  28.     }
  29.     return s/k;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement