VB上机题用多项式求出圆周率的近似值
问题描述:
VB上机题用多项式求出圆周率的近似值
Private Sub Form_click()
p1 = 1
p2 = 1
p3 = p1
i = 1
Do While p3 > 0.0000001 *
p2 = (-1) * p2
p3 = p2 / (i + 1) *
p1 = p1 + p2 *
i = i + 1
Loop
Print p1 * 4
End Sub
打*号的又错,求改正!
答
Private Sub Form_click() p1 = 1 p2 = 1 p3 = p1 i = 1 Do While Abs(p3) > 0.0000001'p3要取绝对值 p2 = (-1) * p2 p3 = p2 / (i + 1) p1 = p1 + p3 '这里p2改为p3 i = i + 1 Loop Print p1 * 4End Su...哪个公式不对?程序算出的值是2.7725
请问数学公式是什么?派/4=1-1/3+1/5-1/7+1/9……Private Sub Form_click()
p1 = 1
p2 = 1
p3 = p1
i = 1
Do While Abs(p3) > 0.0000001'p3要取绝对值
p2 = (-1) * p2
p3 = p2 / (2 * i + 1) '''''''' '改这个就成功了
p1 = p1 + p3 '这里p2改为p3
i = i + 1
Loop
Print p1 * 4
End Sub