用VB计算π的近似值 如图所示
1个回答
展开全部
Private Sub Command1_Click()
Print pi(50)
Print pi(1000)
End Sub
Function pi(n As Double) As Double
Dim s As Double
Dim i As Double
s = 2
For i = 1 To n
s = s * (2 * i) ^ 2 / ((2 * i - 1) * (2 * i + 1))
Next
pi = s
End Function
Print pi(50)
Print pi(1000)
End Sub
Function pi(n As Double) As Double
Dim s As Double
Dim i As Double
s = 2
For i = 1 To n
s = s * (2 * i) ^ 2 / ((2 * i - 1) * (2 * i + 1))
Next
pi = s
End Function
追问
系统说print n(50)那里没有声明 怎么办?
追答
print pi(50) 不是n(50)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询