2个回答
展开全部
Private Sub Command1_Click()
For i = 1 To 5
For j = 1 To 5
If i = 1 Or j = 1 Or i = 5 Or j = 5 Then bsum = bsum + a(i, j) '所有靠边元素之和
asum = asum + a(i, j) '所有元素之和
If i = j Or i + j = 6 Then dsum = dsum + a(i, j) '两条对角线元素之和
Next j
Next i
Print "两条对角线元素之和:" & bsum
Print "所有元素之和" & asum
Print "两条对角线元素之和" & dsum
End Sub
For i = 1 To 5
For j = 1 To 5
If i = 1 Or j = 1 Or i = 5 Or j = 5 Then bsum = bsum + a(i, j) '所有靠边元素之和
asum = asum + a(i, j) '所有元素之和
If i = j Or i + j = 6 Then dsum = dsum + a(i, j) '两条对角线元素之和
Next j
Next i
Print "两条对角线元素之和:" & bsum
Print "所有元素之和" & asum
Print "两条对角线元素之和" & dsum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a(5, 5)
For i = 1 To 5
For j = 1 To 5
a(i, j) = i + j
Next
Next
allsum = 0
duisum = 0
bianxume = 0
For i = 1 To 5
For j = 1 To 5
allsum = allsum + a(i, j)
If i = j Or i + j = 6 Then
duisum = duisum + a(i, j)
End If
If i = 1 Or j = 1 Or i = 5 Or j = 5 Then
bianxume = bianxume + a(i, j)
End If
Next
Next
Print allsum
Print duisum
Print bianxume
End Sub
彪悍人生不需要解释,彪悍的代码不需要注释
Dim a(5, 5)
For i = 1 To 5
For j = 1 To 5
a(i, j) = i + j
Next
Next
allsum = 0
duisum = 0
bianxume = 0
For i = 1 To 5
For j = 1 To 5
allsum = allsum + a(i, j)
If i = j Or i + j = 6 Then
duisum = duisum + a(i, j)
End If
If i = 1 Or j = 1 Or i = 5 Or j = 5 Then
bianxume = bianxume + a(i, j)
End If
Next
Next
Print allsum
Print duisum
Print bianxume
End Sub
彪悍人生不需要解释,彪悍的代码不需要注释
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询