pi.cpp

来自「一个可以计算4000位的Pi值的算法」· C++ 代码 · 共 18 行

CPP
18
字号
// Pi.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

//#include <stdlib.h>  
//#include <stdio.h>  

long a=10000,b,c=2800,d,e,f[2801],g;  

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);  
}  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?