利用π/4≈1-1/3+1/5-1/7+… 求π得近似值 最后一项小于0.000001.我的代码是下面这样,算出来π=2.6667?Private Sub Command1_Click()Dim p As Double, n As Long, t As Integer, s As Double p = 1: n = 1: t = 1 Do n = n + 1 s = 1 /

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 00:43:12
利用π/4≈1-1/3+1/5-1/7+… 求π得近似值 最后一项小于0.000001.我的代码是下面这样,算出来π=2.6667?Private Sub Command1_Click()Dim p As Double, n As Long, t As Integer, s As Double  p = 1: n = 1: t = 1  Do  n = n + 1  s = 1 /
xKKQǿYj3q& c hHf1XHm4oRȓ}$;w&VvM͹yPd/ا󎭌usY5*2m8еOޮwlԻ+vmeݯ6M7wG2ٗ Ύ>ozTudrұ'GP(O'?D8[JEeuqz524|w(, s=%(G|pX9ϗ@3,?~'ӻrGlR++milvcy,>퐂['AHn

利用π/4≈1-1/3+1/5-1/7+… 求π得近似值 最后一项小于0.000001.我的代码是下面这样,算出来π=2.6667?Private Sub Command1_Click()Dim p As Double, n As Long, t As Integer, s As Double p = 1: n = 1: t = 1 Do n = n + 1 s = 1 /
利用π/4≈1-1/3+1/5-1/7+… 求π得近似值 最后一项小于0.000001.我的代码是下面这样,算出来π=2.6667?
Private Sub Command1_Click()
Dim p As Double, n As Long, t As Integer, s As Double
p = 1: n = 1: t = 1

Do
n = n + 1
s = 1 / (2 * n - 1)
t = -t
p = p + t * s
Loop While s < 0.000001
Print 4 * p, p
End Sub
哪里不对,请指出来?我算出来4 * p=2.6666666667.

利用π/4≈1-1/3+1/5-1/7+… 求π得近似值 最后一项小于0.000001.我的代码是下面这样,算出来π=2.6667?Private Sub Command1_Click()Dim p As Double, n As Long, t As Integer, s As Double p = 1: n = 1: t = 1 Do n = n + 1 s = 1 /
Loop While s > 0.000001

这里是大于号

看不懂...

中间的计算没什么毛病
Print 4 * p, p
最后等程序结束了才可以print 4p