编写一个由一位随机整数构成的5*5数组每一行与每一列之和
我不会代码啊,尽量帮帮我拉,小女子会万分感谢!
Option Explicit
Private Sub Command1_Click()
Randomize
Cls
Dim Mat(5, 5) As Integer
Dim i As Integer, j As Integer
For i = 0 To 4
For j = 0 To 4
Mat(i, j) = Rnd * 100 '//生成随机数
Next
Next
For i = 0 To 4
For j = 0 To 4
Print Mat(i, j); '//输出这些随机数
Next
Print
Next
Dim RowsCount(5) As Integer '//各行的总和
Dim ColsCount(5) As Integer '//各列的总和
For i = 0 To 4
For j = 0 To 4
RowsCount(i) = RowsCount(i) + Mat(i, j) '//循环求出各行的总和
Next
Next
For i = 0 To 4
For j = 0 To 4
ColsCount(j) = ColsCount(j) + Mat(i, j) '//循环求出各列的总和
Next
Next
For i = 0 To 4
Print "第" & i & "行的和是:" & RowsCount(i) '//输出各行的和
Next
For i = 0 To 4
Print "第" & i & "列的和是:" & ColsCount(i) '//输出各列的和
Next
End Sub