VB求s=1+2/(1+2)+3/(1+2+3)+4/(1+2+3+4)+.+100/(1+2+3+.+100)的值我用VB求这个式子的值:列了一个式子Private Sub Command1_Click()s = 1: i = 1: s1 = 1For i = 1 To 100s1 = s1 + 1s = s + (i + 1) / (s1 + i + 1)Next iLabel2 = sEnd Sub问一
来源:学生作业帮助网 编辑:六六作业网 时间:2024/08/26 00:46:02
VB求s=1+2/(1+2)+3/(1+2+3)+4/(1+2+3+4)+.+100/(1+2+3+.+100)的值我用VB求这个式子的值:列了一个式子Private Sub Command1_Click()s = 1: i = 1: s1 = 1For i = 1 To 100s1 = s1 + 1s = s + (i + 1) / (s1 + i + 1)Next iLabel2 = sEnd Sub问一
VB求s=1+2/(1+2)+3/(1+2+3)+4/(1+2+3+4)+.+100/(1+2+3+.+100)的值
我用VB求这个式子的值:列了一个式子
Private Sub Command1_Click()
s = 1: i = 1: s1 = 1
For i = 1 To 100
s1 = s1 + 1
s = s + (i + 1) / (s1 + i + 1)
Next i
Label2 = s
End Sub
问一下错了吗?错在哪里了?
VB求s=1+2/(1+2)+3/(1+2+3)+4/(1+2+3+4)+.+100/(1+2+3+.+100)的值我用VB求这个式子的值:列了一个式子Private Sub Command1_Click()s = 1: i = 1: s1 = 1For i = 1 To 100s1 = s1 + 1s = s + (i + 1) / (s1 + i + 1)Next iLabel2 = sEnd Sub问一
你的程序的问题先从第一次循环开始看i=1
s1=s1+1 '执行完成s1=2
s = s + (i + 1) / (s1 + i + 1) '执行完成s=1+2/(2+1+1) 这明显与题意相差太多了.
改动如下
s = 1: i = 1: s1 = 0
For i = 1 To 100
s1 = s1 + i
s = s + i / s1
Next i
Label2 = s