作业帮 > 综合 > 作业

看看这题c++算π怎么算?4(1 - 1/3 + 1/5 - 1/7 + 1/9 - ...-1/(2n-1) + 1/

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/17 04:56:39
看看这题c++算π怎么算?4(1 - 1/3 + 1/5 - 1/7 + 1/9 - ...-1/(2n-1) + 1/(2n+1))
m(i) = 4(1 - 1/3 + 1/5 - 1/7 + 1/9 - ...-1/(2n-1) + 1/(2n+1))
Write a function that returns m(n) with the following function head.
double pi(int n)
提示
You should submit the implementation of the function but do not submit the main() function.
看看这题c++算π怎么算?4(1 - 1/3 + 1/5 - 1/7 + 1/9 - ...-1/(2n-1) + 1/
#include
#include
double pi(int n)
{
\x09double sum = 1;
\x09for(int i = 1;i