你回答的一道程序设计题:vb产生一个6×6的转置矩阵,将二维数组中所有行和对应列的元素进行交换。

2024-11-29 09:54:13
推荐回答(1个)
回答1:

那应该是你的数组的问题吧,
也就是a(m, n),这需要赋值的,下面是一个实例

Private Sub Command1_Click()
Dim a(5, 5)
'赋值
For m = 0 To 5
For n = 0 To 5
a(m, n) = n
Print a(m, n);
Next
Print
Next

Print
Print
Dim czjl(5, 5) As Boolean '转置过程记录
For m = 0 To 5
For n = 0 To 5
If czjl(m, n) = False Then
tmp = a(m, n) 'a是你需要转置数组
a(m, n) = a(n, m)
a(n, m) = tmp
czjl(m, n) = True
czjl(n, m) = True

End If
Next

Next

'转制以后打印
For m = 0 To 5
For n = 0 To 5
'a(m, n) = n
Print a(m, n);
Next
Print
Next

End Sub