主题:求π的程序
QUICKBASIC
[专家分:50] 发布于 2009-07-17 16:53:00
如题,50分
回复列表 (共1个回复)
沙发
1054122 [专家分:750] 发布于 2009-07-17 16:56:00
CLS
INPUT "Save ? ( y or n ) ", a$
IF a$ = "y" OR a$ = "Y" THEN
OPEN "c:\save.dat" FOR OUTPUT AS #1
END IF
DIM m, n, i, p AS DOUBLE
DIM x, y AS LONG
LET n# = 1.797693134862315D+308
LET m# = 0
FOR i# = 1 TO n# STEP 1
LET x& = RND
LET y& = RND
IF x& * x& + y& * y& <= 1 THEN m# = m# +
NEXT i#
p# = m# / n# * 4
IF a$ = "y" OR a$ = "Y" THEN
PRINT #1, "Pai="; p#
ELSE
PRINT "Pai ="; p#
END IF
PRINT "Save to C:\save.dat"
SLEEP
END
高精确度+C盘保存功能
我来回复