vb中怎样编写“1+(1+2)+(1+2+3)+(1++2+3+4)+。。。。。。”程序
2个回答
展开全部
Private Sub Command1_Click()
Dim i, j, n, sum1, sum2 As Integer
n = InputBox("请输入n")
sum1 = 0
sum2 = 1
For i = 1 To n
For j = 1 To i
sum1 = sum1 + j
Next j
sum2 = sum2 + sum1
Next i
End Sub
Dim i, j, n, sum1, sum2 As Integer
n = InputBox("请输入n")
sum1 = 0
sum2 = 1
For i = 1 To n
For j = 1 To i
sum1 = sum1 + j
Next j
sum2 = sum2 + sum1
Next i
End Sub
追问
好像不能运行
追答
Private Sub Command1_Click()
Dim i, j, n, sum As Integer
n = InputBox("请输入n")
sum1 = 0
For i = 1 To n
For j = 1 To i
sum = sum + j
Next j
Next i
Print sum
End Sub
是这个,原来那个有点问题。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询