...5,5),编程计算所有元素的和,所有靠边元素的和,两条对角线元素...
发布网友
发布时间:2024-02-07 14:27
我来回答
共1个回答
热心网友
时间:2024-10-06 03:11
Private Sub Form_Click()
Cls
Randomize
Dim a(5, 5) As Integer
For i = 0 To 5
For j = 0 To 5
a(i, j) = Int(Rnd * 9)
Print a(i, j) & ",";
Sum = Sum + a(i, j)
Next j
Print
Next i
Print "所有元素和为:" & Sum
'////////////
Sum = 0
For i = 0 To 5
Sum = Sum + a(i, 0) + a(i, 5) + a(0, i) + a(5, i)
Next
Sum = Sum - a(0, 0) - a(5, 0) - a(5, 5) - a(0, 5)
Print "所有靠边元素的和:" & Sum
'//////////////////////////////
Sum = 0
For i = 0 To 5
Sum = Sum + a(i, i) + a(i, 5 - i)
Next
Print "两条对角线元素的和为:" & Sum
End Sub