Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define _USE_MATH_DEFINES
- #include <cmath>
- using namespace std;
- double Calc(double epsilon){
- double a = 1.0;
- int i = 1;
- double res = 0.0;
- while(abs(a) > epsilon){
- res+=a;
- a= - a * ( (2.0*i-1.0) / (2.0*i+1.0) );
- i++;
- }
- return res;
- }
- int main() {
- double epsilon,res;
- cin >> epsilon;
- res = Calc(epsilon);
- cout << res;
- cout << endl << M_PI / 4 ;
- }
Add Comment
Please, Sign In to add comment