@echo off&setlocal enabledelayedexpansion
echo %time%
set /a a=10000,c=100
::此处的 c=100 代表精度为 100 位,以 4 位精度为一截向下取整,即 99 等效于 96
(set /a "a/=5,c=c/4*14-1"
for /l %%a in (1 1 !c!) do set f[%%a]=!a!
for /l %%i in (!c! -14 0) do (
for /l %%j in (%%i -1 1) do (
set /a d+=f[%%j]*%a%,f[%%j]=d%%(%%j*2+1^),d=d/(%%j*2+1^)*%%j
)
set /a c=a+d/%a%,a=d%%%a%+%a%,d=0
set /p=!c:~-4!
)
)<nul
echo&echo %time%
pause
#include #include main() { double t,pilong int n,st=1.0n=1s=1pi=0.0while (fabs(t)>=1e-6) { pi=pi+tn=n+2s=-st=(float)(s)/(float)(n)} pi=pi*4printf(" pi=%lf\n",pi)}欢迎分享,转载请注明来源:内存溢出
评论列表(0条)