fork(2) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double ch(double x, double e)
  6. {
  7. double result = 1;
  8. double member = 1;
  9. for (int i = 1; abs(member) >= e; i++)
  10. {
  11. member *= x * x;
  12. member /= 2*i * (2*i - 1);
  13. result += member;
  14. }
  15. return result;
  16. }
  17.  
  18. int main()
  19. {
  20. double x, e;
  21. cin >> x >> e;
  22. cout << ch(x, e);
  23. return 0;
  24. }
Success #stdin #stdout 0s 3464KB
stdin
0.11 0.001
stdout
1.00606