城管工作服:VB编程老鸟进来啊
来源:百度文库 编辑:查人人中国名人网 时间:2024/09/02 03:46:07
1/2+2/3+3/4+......+99/100的和.的程序怎么写速回!!! 先谢谢了.
问题补充:这个是VB的程序从1/2到99/100的累加和啊.不是C语言编程啊
问题补充:这个是VB的程序从1/2到99/100的累加和啊.不是C语言编程啊
Dim I As Integer, S As Double
S = 0
For I = 1 To 99
S = S + I/(I + 1)
Next
注意的是,“和”的数据类型要设置成浮点类型(Single或者Double)
i=0,s=0
for i=1 to 100
s=s+i/(i+1)
没学过VB,这样应该能行吧
Private Sub Command1_Click()
Dim i As Integer, sum As Single
For i = 1 To 99
sum = sum + i / (i + 1)
Next
MsgBox sum
End Sub