用vb 求π Private Sub Form_Click()Dim i As Long,pi As Double,k As Integer,m As Doublei = 1k = 1pi = 0m = 1While (m > 0.00001)m = 1 / (2 * i - 1)pi = pi + k * mi = i + 1k = -kWendPrint "π "; 4 * piEnd SubPrivate Sub Form_Click()Dim pi,c,s As Single

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 13:47:50
用vb 求π Private Sub Form_Click()Dim i As Long,pi As Double,k As Integer,m As Doublei = 1k = 1pi = 0m = 1While (m > 0.00001)m = 1 / (2 * i - 1)pi = pi + k * mi = i + 1k = -kWendPrint
xMKAǿʣ'_5CBdAx ]wRԩJ/ַhf<3oWY|ڂ:n]FqcUK$ ;Zf,X8E5TC$.6$ P #d#%YDHd!EAJA#5M2ħB8oCd=JmƜ9b5ɕ1LisakEo,cDB^'>3cqXK(' EAeN,h*(ȆJT^ajh;Oll"w=o&7lz } W~gDlAo/_C%^7biI܌K ]6 B[

用vb 求π Private Sub Form_Click()Dim i As Long,pi As Double,k As Integer,m As Doublei = 1k = 1pi = 0m = 1While (m > 0.00001)m = 1 / (2 * i - 1)pi = pi + k * mi = i + 1k = -kWendPrint "π "; 4 * piEnd SubPrivate Sub Form_Click()Dim pi,c,s As Single
用vb 求π
Private Sub Form_Click()
Dim i As Long,pi As Double,k As Integer,m As Double
i = 1
k = 1
pi = 0
m = 1
While (m > 0.00001)
m = 1 / (2 * i - 1)
pi = pi + k * m
i = i + 1
k = -k
Wend
Print "π "; 4 * pi
End Sub
Private Sub Form_Click()
Dim pi,c,s As Single
pi = 0
s = 1
For c = 1 To 10000 Step 2
pi = pi + s / c
s = -s
Next c
Print "π="; pi * 4
End Sub

用vb 求π Private Sub Form_Click()Dim i As Long,pi As Double,k As Integer,m As Doublei = 1k = 1pi = 0m = 1While (m > 0.00001)m = 1 / (2 * i - 1)pi = pi + k * mi = i + 1k = -kWendPrint "π "; 4 * piEnd SubPrivate Sub Form_Click()Dim pi,c,s As Single
这是级别展开式,你学到高等数学就会明白的
pi/4=1-1/3!+1/5!-1/7!+...