VB 编写 6行6列矩阵,并转置,用图片框显示
单击按钮,在图片框中生成包含[1,10]之间的随机整数的6行6列的矩阵,单击转置对矩阵进行转置,显示与另一个图片框中...
单击按钮,在图片框中生成包含[1,10]之间的随机整数的6行6列的矩阵,单击转置对矩阵进行转置,显示与另一个图片框中
展开
2个回答
展开全部
'例子需控件:Command1、Picture1、Picture2
Dim Zu() As String
Private Sub Form_Load()
'初凳坦始化6行6列枣腔桐矩阵
Dim I As Long, J As Long
ReDim Zu(1 To 6, 1 To 6)
For I = 1 To 6
For J = 1 To 6
Randomize
Zu(I, J) = 1 + Int(Rnd * 9) 'I & "-" & J
Next
Next
Command1.Caption = "显示"
End Sub
Private Sub Command1_Click()
Dim I As Long, J As Long, JL As Single
JL = Picture1.TextHeight("A") * 3
Picture1.Cls: Picture1.AutoRedraw = True
Picture2.Cls: Picture2.AutoRedraw = True
For I = 1 To 6
For J = 1 To 6
Picture1.CurrentX = I * JL: Picture1.CurrentY = J * JL
Picture1.Print Zu(I, J) '默认显示
Picture2.CurrentX = I * JL: Picture2.CurrentY = J * JL
Picture2.Print Zu(J, I) '行列互换
'圆液Picture2.Print Zu(7 - I, J) '左右翻转
' Picture2.Print Zu(I, 7 - J) '上下翻转
Next
Next
End Sub
Dim Zu() As String
Private Sub Form_Load()
'初凳坦始化6行6列枣腔桐矩阵
Dim I As Long, J As Long
ReDim Zu(1 To 6, 1 To 6)
For I = 1 To 6
For J = 1 To 6
Randomize
Zu(I, J) = 1 + Int(Rnd * 9) 'I & "-" & J
Next
Next
Command1.Caption = "显示"
End Sub
Private Sub Command1_Click()
Dim I As Long, J As Long, JL As Single
JL = Picture1.TextHeight("A") * 3
Picture1.Cls: Picture1.AutoRedraw = True
Picture2.Cls: Picture2.AutoRedraw = True
For I = 1 To 6
For J = 1 To 6
Picture1.CurrentX = I * JL: Picture1.CurrentY = J * JL
Picture1.Print Zu(I, J) '默认显示
Picture2.CurrentX = I * JL: Picture2.CurrentY = J * JL
Picture2.Print Zu(J, I) '行列互换
'圆液Picture2.Print Zu(7 - I, J) '左右翻转
' Picture2.Print Zu(I, 7 - J) '上下翻转
Next
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim a(1 To 6, 1 To 6) As Integer
Private Sub Command1_Click()
Randomize
For j = 1 To 6
For i = 1 To 6
a(j, i) = Int(Rnd * (10) + 1)
Picture1.Print Format(a(j, i), "00"); "敏李拆桥枣 "扰岁;
Next i
Picture1.Print
Next j
End Sub
Private Sub Command2_Click()
For j = 1 To 6
For i = 1 To 6
Picture2.Print Format(a(i, j), "00"); " ";
Next i
Picture2.Print
Next j
End Sub
Private Sub Command1_Click()
Randomize
For j = 1 To 6
For i = 1 To 6
a(j, i) = Int(Rnd * (10) + 1)
Picture1.Print Format(a(j, i), "00"); "敏李拆桥枣 "扰岁;
Next i
Picture1.Print
Next j
End Sub
Private Sub Command2_Click()
For j = 1 To 6
For i = 1 To 6
Picture2.Print Format(a(i, j), "00"); " ";
Next i
Picture2.Print
Next j
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询