Advertisement
myloyo

5.4.8

Nov 20th, 2022 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7. double eps = 1e-9;
  8. double f(double x) {
  9.     double s, a, c = x;
  10.     int i = 1, z = 1;
  11.     s = 1;
  12.     i = 1;
  13.     a = 1;
  14.     while (a >= eps) {
  15.         z = (2 * i) * (2 * i + 2);
  16.         c *= x;
  17.         a = c / z;
  18.         s += a;
  19.         i++;
  20.     }
  21.     return s;
  22. }
  23.  
  24. int main()
  25. {
  26.     double h;
  27.     int i;
  28.     cin >> h;
  29.  
  30.     for (double i = 0.2; i <= 0.6 + eps; i += h) {
  31.         cout << i << " " << f(i) << endl;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement