vb试题编程计算1-1/2+1/3-1/4+...+1/99-1/100,单击窗体后,在窗体上显示结果。
PrivateSubForm_Click()DimsAsSingleDimiAsIntegers=0Fori=1To100Step1IfiMod2<>0Thens=s+1...
Private Sub Form_Click()
Dim s As Single
Dim i As Integer
s = 0
For i = 1 To 100 Step 1
If i Mod 2 <> 0 Then
s = s + 1 / i
Else
s = s - 1 / i
End If
Next i
Print "s="; s
End Sub 展开
Dim s As Single
Dim i As Integer
s = 0
For i = 1 To 100 Step 1
If i Mod 2 <> 0 Then
s = s + 1 / i
Else
s = s - 1 / i
End If
Next i
Print "s="; s
End Sub 展开
2个回答
展开全部
Private Sub Form_Click()
Dim s, i As Integer
s = 0
For i = 1 To 100 Step 1
If i Mod 2 <> 0 Then
s = s + 1 / i
Else
s = s - 1 / i
End If
Next i
Print "s="; "0" & s
End Sub
Dim s, i As Integer
s = 0
For i = 1 To 100 Step 1
If i Mod 2 <> 0 Then
s = s + 1 / i
Else
s = s - 1 / i
End If
Next i
Print "s="; "0" & s
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询