题目是这样的
编写从“sum=1+1/3+1/5+.....1/99“计算总和sum,要用FOR语句,我编了几次,实在不会,本人初学VB,望达人帮忙一下,谢谢。
题目是这样的
编写从“sum=1+1/3+1/5+.....1/99“计算总和sum,要用FOR语句,我编了几次,实在不会,本人初学VB,望达人帮忙一下,谢谢。
Private Sub Command1_Click()
Dim s As Single
s = 0
For i = 1 To 99 Step 2
s = s + 1 / i
Next i
Print Format(s, "0.000")
End Sub
干嘛不直接找我……
dim i as intger
dim s as intger
s=1
for i from 1 to 99 step 2
s=s+1/i
next
print s