[原创]圆周率PI的计算(精确到几十万位)
//环境:VC6.0,Console Application
//原理:π=2+1/3*(2+2/5*(2+3/7*(2+...
//特点:内嵌汇编提速并扩大了计算范围
//限制:位数ws原则上没有限制但因为本
//算法的时间正比于ws的平方所以将位数
//控制在二、三十万以内较好。本人曾用
//奔Ⅳ2.6GHz算20万位,耗时10分钟左右
#include
#include
#include
#include
long a=100000L;
void main()
{ FILE *fp;
long t1,t2;
char filename[40];
unsigned long c,d,e,i,j,ws;
unsigned long *f,*bb;
printf("位数=?");
scanf("%ld",&ws);
if(ws<1)return;
c=(ws+4)/05*17;
bb=f=(long*)malloc(04*c);
if(f==NULL)abort();
printf("将Pi存为: ");//提示输入数据文件名
scanf("%s",filename);//若打入NUL,则不存盘
fp=fopen(filename,"w");
if(fp==NULL)abo