/*
*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++;
}
cout("%f",4*sum);
}
/*
*copyright(c) 2014,烟台大学计算机学院
*All rights reserved
*文件名称:test.cpp
*作者:李旭
*版本:v6.0
*
*问题描述:输出finonaccl小于10000的数字
*输入描述:无
*程序输出:输出10000的数
*/
#include<iostream>
using namespace std;
int main()
{
int y=1,i;
int a[1000];
a[0]=1,a[1]=1;
for(i=2;i<=100;i++)
{
a[i]=a[i-1]+a[i-2];
if(a[i]>10000)
break;
y++;
}
for(i=0;i<y;i++)
cout("%d ",a[i]);
}
*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++;
}
cout("%f",4*sum);
}
/*
*copyright(c) 2014,烟台大学计算机学院
*All rights reserved
*文件名称:test.cpp
*作者:李旭
*版本:v6.0
*
*问题描述:输出finonaccl小于10000的数字
*输入描述:无
*程序输出:输出10000的数
*/
#include<iostream>
using namespace std;
int main()
{
int y=1,i;
int a[1000];
a[0]=1,a[1]=1;
for(i=2;i<=100;i++)
{
a[i]=a[i-1]+a[i-2];
if(a[i]>10000)
break;
y++;
}
for(i=0;i<y;i++)
cout("%d ",a[i]);
}