Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- using namespace std;
- int tw = 2, svn = 7;
- double x, current_x;
- int cur = 1;
- double abs(double a){return a > 0 ? a : -a;}
- double next(int i)
- {
- return (current_x * x)/(tw * i * svn * i);
- }
- int main()
- {
- cout << "Enter 'X' : ";
- cin >> x;
- double eps;
- cout << "Enter 'eps' : ";
- cin >> eps;
- double answer = 1;
- current_x = -1;
- int i = 1;
- while (abs(next(i)) >= eps )
- {
- answer += next(i++);
- current_x *= -x;
- }
- cout << answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement