编程题:用π/4≈1-1/3+1/5-1/7+……公式求π的近似值,直到最后一项绝对值小于10^-6为止 do_while 循环
1个回答
展开全部
Private Sub Command1_Click()
Dim sign As Integer, a As Long, pi As Double
Dim i As Integer
sign = -1
i = 1
Do
a = 2 * i - 1
sign = -1 * sign
pi = pi + (1 / a) * sign
i = i + 1
Loop While Abs((1 / a) * sign) > 0.0001
pi = pi * 4
Print pi
End Sub
追问
C语言
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询