/*
*copyright(c) 2016,烟台大学计算机学院
*All rights reserved
*文件名称:test.cpp
*作者:徐伟
*版本:v6.0
*
*问题描述: 计算输出pai的值
*输入描述:无
*程序输出:输出答案
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double sum=0;
int temp=-1;
double shu=1;
int t=2,y=2;
while(fabs(shu)>=1e-5)
{
sum=sum+shu;
t=2*y-1;
shu=1.0/t;
shu=shu*temp;
temp=-temp;
y++;
}
printf("%f",4*sum);
}

被折叠的 条评论
为什么被折叠?



