vb题:求s的值。s=1+(1+2)+(1+2+3)+(1+2+3+4)+……+(1+2+3+4+……+N)(令N=50)
3个回答
展开全部
Private Sub Command1_Click()
Dim N As Integer, S As Double, x As Double
Dim i As Integer, j As Integer
N = Val(InputBox("请输入不大于100的自然数N:", "计算", 50))
S = 0
For i = 1 To N
x = 0
For j = 1 To i
x = x + 1
S = S + x
Next j
Next i
Print "当N=" & N & "时,结果为:" & S
End Sub
Dim N As Integer, S As Double, x As Double
Dim i As Integer, j As Integer
N = Val(InputBox("请输入不大于100的自然数N:", "计算", 50))
S = 0
For i = 1 To N
x = 0
For j = 1 To i
x = x + 1
S = S + x
Next j
Next i
Print "当N=" & N & "时,结果为:" & S
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询