编程计算S=1+(1+2)+(1+2+3)+…+(1+2+3+4+…+100)的值?请各位用VB程序的代码打出来。

лл
2024-11-17 20:47:38
推荐回答(3个)
回答1:

Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim a As Long
For i = 1 To 100
a = a + ss(i)
Next i
Print a
End Sub

Function ss(n As Integer)
Dim i As Integer
For i = 1 To n
ss = ss + n
Next i

End Function

回答2:

Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim a As Long
For i = 1 To 100
a = a + ss(i)
Next i
Print a
End Sub

Function ss(n As Integer)
Dim i As Integer
For i = 1 To n
ss = ss + n
Next i

End Function
vc要么?

回答3:

不会