以下程序段用于实现矩阵转置,即将一个n×m的矩阵的行和列互换 ✀ ✀请在【】处填入正确的内容

2024-11-25 16:24:10
推荐回答(1个)
回答1:

Private Sub Command1_Click()

Randomize Timer
Dim n As Integer, m As Integer
Dim arr1() As Integer, arr2() As Integer
Dim i As Integer, j As Integer
n = InputBox("请输入矩阵的行数")
m = InputBox("请输入矩阵的列数")
ReDim arr1(1 To n, 1 To m), arr2(1 To m, 1 To n)
For i = 1 To n
For j = 1 To m
arr1(i, j) = Int(Rnd * 10)
Print arr1(i, j);
Next
Print
Next

For i = 1 To m
For j = 1 To n
arr2(i, j) = arr1(j, i)
Print arr2(i, j);
Next
Print
Next

End Sub