求算法,在VB中如何实现矩阵A(3,3)与矩阵B(3,3)相乘?
1个回答
展开全部
直接复制代码 就可以了 按F5 运行: OK
Private Sub Form_Load()
Show
Dim i As Integer, j As Integer
Dim a(3, 3) As Integer, b(3, 3) As Integer, c(3, 3) As Integer
Randomize
Print "a(3,3)矩阵"
For i = 0 To 3
For j = 0 To 3
a(i, j) = Int(Rnd * 10 + 1)
Print a(i, j);
Next j
Print
Next i
Print "b(3,3)矩阵"
For i = 0 To 3
For j = 0 To 3
b(i, j) = Int(Rnd * 10 + 1)
Print b(i, j);
Next j
Print
Next i
Print "c(3,3)矩阵"
For i = 0 To 3
For j = 0 To 3
c(i, j) = a(i, j) * b(i, j)
Print c(i, j);
Next j
Print
Next i
End Sub
Private Sub Form_Load()
Show
Dim i As Integer, j As Integer
Dim a(3, 3) As Integer, b(3, 3) As Integer, c(3, 3) As Integer
Randomize
Print "a(3,3)矩阵"
For i = 0 To 3
For j = 0 To 3
a(i, j) = Int(Rnd * 10 + 1)
Print a(i, j);
Next j
Next i
Print "b(3,3)矩阵"
For i = 0 To 3
For j = 0 To 3
b(i, j) = Int(Rnd * 10 + 1)
Print b(i, j);
Next j
Next i
Print "c(3,3)矩阵"
For i = 0 To 3
For j = 0 To 3
c(i, j) = a(i, j) * b(i, j)
Print c(i, j);
Next j
Next i
End Sub
更多追问追答
追问
话说,在线性代数中,矩阵相乘好像是按照“左取行右取列”的法则吧!不是简单的每个元素相乘吧~~~
追答
左取行右取列? 解释下
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询