vb求两个矩阵的和
2个回答
展开全部
Option Base 1
Private Sub Command1_Click()
Dim sum As Long
x = Val(InputBox("输入行数"))
y = Val(InputBox("输入列数"))
ReDim a(x, y) As Integer, b(x, y) As Integer
For i = 1 To x
For j = 1 To y
a(i, j) = Val(InputBox("输入a矩阵" & i & "行" & j & "列数据"))
b(i, j) = Val(InputBox("输入b矩阵" & i & "行" & j & "列数据"))
sum = sum + a(i, j) + b(i, j)
Next j
Next i
Print sum
End Sub
Private Sub Command1_Click()
Dim sum As Long
x = Val(InputBox("输入行数"))
y = Val(InputBox("输入列数"))
ReDim a(x, y) As Integer, b(x, y) As Integer
For i = 1 To x
For j = 1 To y
a(i, j) = Val(InputBox("输入a矩阵" & i & "行" & j & "列数据"))
b(i, j) = Val(InputBox("输入b矩阵" & i & "行" & j & "列数据"))
sum = sum + a(i, j) + b(i, j)
Next j
Next i
Print sum
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询