计算圆周率800位的程序
#include
long a=10000, b, c=2800, d, e, f[2801], g;
void main(){
for(;b-c;)f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)
for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
}
==================
你的程序应该吧 1e-7 改为 更小的数就行了,比如1e-10
在输出最后一句之前,加上
cout.precision(7);
7表示小数点后保留7位