Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. const double eps = 1e-6;
  7.  
  8.  
  9. signed main()
  10. {
  11. double a,b,h;
  12. a = 0, b = 3, h = 0.3;
  13.  
  14. for (double x = a; x<=b; x+=h)
  15. {
  16. double sign = 1;
  17. double chisl = 1;
  18. double znam = 1;
  19. double i = 1;
  20. double sum= 0;
  21. double cnt = 0;
  22. do
  23. {
  24. cnt = sign*chisl/znam;
  25. sum+=cnt;
  26.  
  27. znam *=i*i;
  28. i++;
  29. chisl*=x*x/4;
  30. sign *=-1;
  31. }
  32. while (fabs(cnt)>=eps);
  33.  
  34. cout << fixed << setprecision(6) << x<< " "<< sum << endl;
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement