vb 编写一个程序,将一个矩阵转置,即行列元素对换。
2个回答
展开全部
Private Sub Command1_Click()
Dim a() As Integer, b() As Integer
n = InputBox("请输入阶数n:")
ReDim a(n, n)
For i = 1 To n
For j = 1 To n
a(i, j) = InputBox("请输入a(" & i & "," & j & ")")
Print a(i, j);
Next j
Print
Next i
Print
ReDim b(n, n)
Print "转置后:"
For i = 1 To n
For j = 1 To n
b(j, i) = a(i, j)
Next j
Next i
For i = 1 To n
For j = 1 To n
Print b(i, j);
Next j
Print
Next i
End Sub
Dim a() As Integer, b() As Integer
n = InputBox("请输入阶数n:")
ReDim a(n, n)
For i = 1 To n
For j = 1 To n
a(i, j) = InputBox("请输入a(" & i & "," & j & ")")
Print a(i, j);
Next j
Next i
ReDim b(n, n)
Print "转置后:"
For i = 1 To n
For j = 1 To n
b(j, i) = a(i, j)
Next j
Next i
For i = 1 To n
For j = 1 To n
Print b(i, j);
Next j
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询