Informatics Olympiad a general answer dj to find the value of π 1156

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double arctanx(double x)
{
	double sum=0,tmp=x;
	for(int i=1;;i+=2)
	{
		sum+=(tmp/i);
		tmp=-1*tmp*x*x;
		if(fabs(tmp/i)<1e-6) break;
	}
	return sum;
}
int main()
{
	printf("%.10lf",6*arctanx(1/sqrt(3)));
	return 00;
	return 0;
}

If you want answers to other questions, hacker applets, or C++ basics, follow me.

Ask for likes!

Guess you like

Origin blog.csdn.net/m0_73220913/article/details/129737181