VB编程求sum=1+1⼀2+1⼀3+...+1⼀n

2024-11-17 12:25:16
推荐回答(3个)
回答(1):

Private Sub Form_Click()
Dim i As Integer
Dim sum As Double
Dim t As Double
sum = 0
i = 1
t = 1 / i
Do While t > 0.0001
sum = sum + t
i = i + 1
t = 1 / i
Loop
Debug.Print "i="; i; "sum="; sum

End Sub

回答(2):

一楼说的好,你倒是给答案啊
主体:
double n=1,sum=0
do
{
sum=sum+1/n
n=n+1
}
while(1/n>0.0001)
loop
print n

回答(3):

简单、