如何在vb的窗体中并排输入两个矩阵?
我的程序如下,但ABCD四个矩阵都是竖排排列的,我想让AB并列,CD并列,请问该怎么改?OptionBase1PrivateSubForm_load()Dima(3,4)...
我的程序如下,但ABCD四个矩阵都是竖排排列的,我想让AB并列,CD并列,请问该怎么改?
Option Base 1
Private Sub Form_load()
Dim a(3, 4) As Integer, b(3, 4) As Integer, c(3, 4) As Integer, d(3, 4) As Integer
Show
For i = 1 To 3
For j = 1 To 4
a(i, j) = Int(89 * Rnd + 10)
Next j
Next i
Print "A矩阵为:"
Print
For i = 1 To 3
For j = 1 To 4
Print Tab(5 * j); a(i, j);
Next j
Print
Next i
For i = 1 To 3
For j = 1 To 4
b(i, j) = Int(10 * Rnd + 0)
Next j
Next i
Print "B矩阵为:"
Print
For i = 1 To 3
For j = 1 To 4
Print Tab(5 * j); b(i, j);
Next j
Print
Next i
Print "C矩阵为:"
Print
For i = 1 To 3
For j = 1 To 4
c(i, j) = a(i, j) + b(i, j)
Print Tab(5 * j); c(i, j);
Next j
Print
Next i
Print "D矩阵为:"
Print
For i = 1 To 3
For j = 1 To 4
d(i, j) = a(i, j) - b(i, j)
Print Tab(5 * j); d(i, j);
Next j
Print
Next i
End Sub 展开
Option Base 1
Private Sub Form_load()
Dim a(3, 4) As Integer, b(3, 4) As Integer, c(3, 4) As Integer, d(3, 4) As Integer
Show
For i = 1 To 3
For j = 1 To 4
a(i, j) = Int(89 * Rnd + 10)
Next j
Next i
Print "A矩阵为:"
For i = 1 To 3
For j = 1 To 4
Print Tab(5 * j); a(i, j);
Next j
Next i
For i = 1 To 3
For j = 1 To 4
b(i, j) = Int(10 * Rnd + 0)
Next j
Next i
Print "B矩阵为:"
For i = 1 To 3
For j = 1 To 4
Print Tab(5 * j); b(i, j);
Next j
Next i
Print "C矩阵为:"
For i = 1 To 3
For j = 1 To 4
c(i, j) = a(i, j) + b(i, j)
Print Tab(5 * j); c(i, j);
Next j
Next i
Print "D矩阵为:"
For i = 1 To 3
For j = 1 To 4
d(i, j) = a(i, j) - b(i, j)
Print Tab(5 * j); d(i, j);
Next j
Next i
End Sub 展开
2个回答
展开全部
参考这个:
Option Base 1
Private Sub Form_load()
Dim a(3, 4) As Integer, b(3, 4) As Integer, c(3, 4) As Integer, d(3, 4) As Integer
Show
Print "A矩阵为:", "", "B矩阵为:"
For i = 1 To 3
For j = 1 To 4
a(i, j) = Int(89 * Rnd + 10)
b(i, j) = Int(10 * Rnd + 0)
Next j
Print a(i, 1); a(i, 2); a(i, 3), "", b(i, 1); b(i, 2); b(i, 3)
Next i
End Sub
Option Base 1
Private Sub Form_load()
Dim a(3, 4) As Integer, b(3, 4) As Integer, c(3, 4) As Integer, d(3, 4) As Integer
Show
Print "A矩阵为:", "", "B矩阵为:"
For i = 1 To 3
For j = 1 To 4
a(i, j) = Int(89 * Rnd + 10)
b(i, j) = Int(10 * Rnd + 0)
Next j
Print a(i, 1); a(i, 2); a(i, 3), "", b(i, 1); b(i, 2); b(i, 3)
Next i
End Sub
更多追问追答
追问
可是AB矩阵不是随机的了,变成了固定不变的
追答
Option Base 1
Private Sub Form_load()
Randomize '加上这个
Dim a(3, 4) As Integer, b(3, 4) As Integer, c(3, 4) As Integer, d(3, 4) As Integer
Show
Print "A矩阵为:", "", "B矩阵为:"
For i = 1 To 3
For j = 1 To 4
a(i, j) = Int(89 * Rnd + 10)
b(i, j) = Int(10 * Rnd + 0)
Next j
Print a(i, 1); a(i, 2); a(i, 3), "", b(i, 1); b(i, 2); b(i, 3)
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询