以下程序段用于实现矩阵转置,即将一个n×m的矩阵的行和列互换 ' '请在【】处填入正确的内容
以下程序段用于实现矩阵转置,即将一个n×m的矩阵的行和列互换''请在【】处填入正确的内容?PrivateSubForm_Click()Constn=3Constm=4Di...
以下程序段用于实现矩阵转置,即将一个n×m的矩阵的行和列互换
'
'请在【】处填入正确的内容?
Private Sub Form_Click()
Const n = 3
Const m = 4
Dim a(n, m), b(m, m) As Integer
For I = 1 To n
For j = 1 To m
a(I, j) = Int(Rnd * 90) + 10
Next j
'**********SPACE**********
【?】
For I = 1 To n
For j = 1 To m
'**********SPACE**********
【?】
Next j
Next I
Print "矩阵转置前"
For I = 1 To n
For j = 1 To m
Print a(I, j);
Next j
'**********SPACE**********
【?】
Next I
Print "矩阵转置后"
For I = 1 To n
For j = 1 To m
Print b(j, I);
Next j
Print
Next I
End Sub 展开
'
'请在【】处填入正确的内容?
Private Sub Form_Click()
Const n = 3
Const m = 4
Dim a(n, m), b(m, m) As Integer
For I = 1 To n
For j = 1 To m
a(I, j) = Int(Rnd * 90) + 10
Next j
'**********SPACE**********
【?】
For I = 1 To n
For j = 1 To m
'**********SPACE**********
【?】
Next j
Next I
Print "矩阵转置前"
For I = 1 To n
For j = 1 To m
Print a(I, j);
Next j
'**********SPACE**********
【?】
Next I
Print "矩阵转置后"
For I = 1 To n
For j = 1 To m
Print b(j, I);
Next j
Next I
End Sub 展开
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
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
Next
For i = 1 To m
For j = 1 To n
arr2(i, j) = arr1(j, i)
Print arr2(i, j);
Next
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询