计算圆周率PI=4-4/3+4/5-4/7.........打印出第一个大于3.1415小于3.1416的值
1个回答
展开全部
3.14150000952847 用vb6.0编程如下
Private Sub Command1_Click()
a = 1
b = 4
For i = 3 To 1000000000 Step 2
b = b + (4 / i) * (-1) ^ a
a = a + 1
If b > 3.1415 And b < 3.1416 Then Exit For
Next i
Text1.Text = b
End Sub
Private Sub Command1_Click()
a = 1
b = 4
For i = 3 To 1000000000 Step 2
b = b + (4 / i) * (-1) ^ a
a = a + 1
If b > 3.1415 And b < 3.1416 Then Exit For
Next i
Text1.Text = b
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询