DECLARE FUNCTION cruz! (X#, Y#, cor!) ' Estima‡„o do valor de ă ' PP, 1997.01 ' ' PontosDentro = 0 PontosFora = 0 SCREEN 12 ' PSET (20, 20) LINE (20, 20)-(320, 20) LINE (20, 20)-(20, 320) LINE (320, 20)-(320, 320) LINE (20, 320)-(320, 320) ' CIRCLE (20, 20), 300, 14, 0, .02 CIRCLE (20, 320), 300, 14, 0, 3.14159 / 2 ' CIRCLE (20, 20), 300, 14 lado = 54 min# = 1# / (lado + 1) max# = 1# - min# + 9.999999999999999D-10 passo# = min# A = TIMER FOR X# = min# TO max# STEP passo# FOR Y# = min# TO max# STEP passo# IF SQR(X# * X# + Y# * Y#) < 1# THEN PontosDentro = PontosDentro + 1 lixo = cruz(X#, 1 - Y#, 2) ELSE PontosFora = PontosFora + 1 lixo = cruz(X#, 1 - Y#, 10) END IF NEXT Y# NEXT X# LOCATE 24, 1 PRINT "ă ÷"; 4# * PontosDentro / (PontosDentro + PontosFora) B = TIMER PRINT PontosDentro + PontosFora; "pontos"; B - A; "SEGS." FUNCTION cruz (X#, Y#, cor) PSET (20 + 300 * X#, 20 + 300 * Y#), cor PSET (20 + 300 * X#, 20 + 300 * Y# + 1), cor PSET (20 + 300 * X#, 20 + 300 * Y# - 1), cor PSET (20 + 300 * X# + 1, 20 + 300 * Y#), cor PSET (20 + 300 * X# - 1, 20 + 300 * Y#), cor END FUNCTION