VB矩阵乘法程序
矩阵A输入程序PrivateSubCommand1_Click()Dima()AsIntegerDimdAsIntegerDimnAsIntegerd=InputBox(...
矩阵A输入程序
Private Sub Command1_Click()
Dim a() As Integer
Dim d As Integer
Dim n As Integer
d = InputBox("请输入A矩阵行数", "提示")
n = InputBox("请输入A矩阵列数", "提示")
ReDim a(d, n) As Integer
For i = 1 To d
For j = 1 To n
a(i, j) = InputBox("请输入矩阵A", "提示")
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
End Sub
矩阵B输入程序
Private Sub Command2_Click()
Dim b() As Integer
Dim c As Integer
Dim m As Integer
c = InputBox("请输入B矩阵行数", "提示")
m = InputBox("请输入B矩阵列数", "提示")
ReDim b(c, m) As Integer
For i = 1 To c
For j = 1 To m
b(i, j) = InputBox("请输入矩阵B", "提示")
Picture2.Print b(i, j);
Next j
Picture2.Print
Next i
Picture2.Print
End Sub
AB矩阵乘法程序(此处不对)
Private Sub Command5_Click()
Dim e() As Integer
Dim k As Integer
ReDim e(d, m) As Integer
For i = 1 To d
For j = 1 To m
e(i, j) = 0
For k = 1 To n
e(i, j) = a(i, k) * b(k, j) + e(i, j)
Next
Picture3.Print e(i, j);
Next
Next
End Sub
最后矩阵相乘运行时显示a(i,k)未定义,求大神啊 展开
Private Sub Command1_Click()
Dim a() As Integer
Dim d As Integer
Dim n As Integer
d = InputBox("请输入A矩阵行数", "提示")
n = InputBox("请输入A矩阵列数", "提示")
ReDim a(d, n) As Integer
For i = 1 To d
For j = 1 To n
a(i, j) = InputBox("请输入矩阵A", "提示")
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
End Sub
矩阵B输入程序
Private Sub Command2_Click()
Dim b() As Integer
Dim c As Integer
Dim m As Integer
c = InputBox("请输入B矩阵行数", "提示")
m = InputBox("请输入B矩阵列数", "提示")
ReDim b(c, m) As Integer
For i = 1 To c
For j = 1 To m
b(i, j) = InputBox("请输入矩阵B", "提示")
Picture2.Print b(i, j);
Next j
Picture2.Print
Next i
Picture2.Print
End Sub
AB矩阵乘法程序(此处不对)
Private Sub Command5_Click()
Dim e() As Integer
Dim k As Integer
ReDim e(d, m) As Integer
For i = 1 To d
For j = 1 To m
e(i, j) = 0
For k = 1 To n
e(i, j) = a(i, k) * b(k, j) + e(i, j)
Next
Picture3.Print e(i, j);
Next
Next
End Sub
最后矩阵相乘运行时显示a(i,k)未定义,求大神啊 展开
2个回答
展开全部
Option Explicit
Dim a() As Integer
Dim b() As Integer
Dim d As Integer
Dim m As Integer
Dim n As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer
d = InputBox("请输入A矩阵行数", "提示")
n = InputBox("请输入A矩阵列数", "提示")
ReDim a(d, n) As Integer
For i = 1 To d
For j = 1 To n
a(i, j) = InputBox("请输入矩阵A", "提示")
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Picture1.Print
End Sub
'矩阵B输入程序
Private Sub Command2_Click()
Dim c As Integer
Dim i As Integer, j As Integer
c = InputBox("请输入B矩阵行数", "提示")
m = InputBox("请输入B矩阵列数", "提示")
ReDim b(c, m) As Integer
For i = 1 To c
For j = 1 To m
b(i, j) = InputBox("请输入矩阵B", "提示")
Picture2.Print b(i, j);
Next j
Picture2.Print
Next i
Picture2.Print
End Sub
'AB矩阵乘法程序 (此处不对)
Private Sub Command5_Click()
Dim e() As Integer
Dim k As Integer
Dim i As Integer, j As Integer
ReDim e(d, m) As Integer
For i = 1 To d
For j = 1 To m
e(i, j) = 0
For k = 1 To n
e(i, j) = a(i, k) * b(k, j) + e(i, j)
Next
Picture3.Print e(i, j);
Next
Next
End Sub
追问
运行结果的矩阵怎么没分行啊,全排在一行了
追答
这个已经不是你提问的问题,我也没想那么多。
分行不分行只是分号的问题,你加一个空print就能解决。
For i = 1 To d
For j = 1 To m
e(i, j) = 0
For k = 1 To n
e(i, j) = a(i, k) * b(k, j) + e(i, j)
Next
Picture3.Print e(i, j);
Next
print ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''这里加一个试试
Next
展开全部
应该是三个Next 后面没有了K,J,I
Next
Picture3.Print e(i, j);
Next
Next
End Sub
还有:如果你输入的C小于N,最后矩阵相乘运行时显示b(k,j)未定义.,所以不要手动输入C,令C=N就安全了。
结果的矩阵怎么没分行,是因为Picture3.Print e(i, j); 最后是“;”
在中的两个 Next之间插一句打印空格,逗号
Next
Picture3.Print 空格,
Next
追答
不采纳我你罪过
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询