VB上机题用多项式求出圆周率的近似值Private Sub Form_click()p1 = 1p2 = 1p3 = p1i = 1Do While p3 > 0.0000001 *p2 = (-1) * p2p3 = p2 / (i + 1) *p1 = p1 + p2 *i = i + 1LoopPrint p1 * 4End Sub打*号的又错,求改正!
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 21:52:38
VB上机题用多项式求出圆周率的近似值Private Sub Form_click()p1 = 1p2 = 1p3 = p1i = 1Do While p3 > 0.0000001 *p2 = (-1) * p2p3 = p2 / (i + 1) *p1 = p1 + p2 *i = i + 1LoopPrint p1 * 4End Sub打*号的又错,求改正!
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
打*号的又错,求改正!
VB上机题用多项式求出圆周率的近似值Private Sub Form_click()p1 = 1p2 = 1p3 = p1i = 1Do While p3 > 0.0000001 *p2 = (-1) * p2p3 = p2 / (i + 1) *p1 = p1 + p2 *i = i + 1LoopPrint p1 * 4End 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 * 4
End Sub
'好像你的公式不对哦