十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Dim a(6, 6) As Integer, i As Integer, ii As Integer
创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于网站制作、做网站、平城网络推广、重庆小程序开发、平城网络营销、平城企业策划、平城品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供平城建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com
Private Sub Command1_Click()
For i = 1 To 6
For ii = 1 To 4
a(i, ii) = Int(Rnd * 90 + 10)
Next ii
Next i
For i = 1 To 6
For ii = 1 To 4
Picture1.Print a(i, ii);
Next ii
Picture1.Print ""
Next i
End Sub
Private Sub Command2_Click()
For ii = 1 To 4
For i = 1 To 6
Picture2.Print a(i, ii);
Next i
Picture2.Print
Next ii
End Sub
VB源程序如下:
Option Base 1
Private Sub Command1_Click()
Dim A(5, 5) As Integer, B(5, 5) As Integer
For x = 1 To 5
For y = 1 To 5
A(x, y) = Int(10 + Rnd * 90) '随机产生两位数的整数
Print A(x, y); '输出
Next
Next
For x = 1 To 5
For y = 1 To 5
B(x, y) = A(y, x) '转置
Print B(x, y); '输出
Next
Next
End Sub
程序输出结果如下:
扩展资料:
VB:编写程序,实现如下规律的5*5矩阵存入数组,并输出该数组
Private Sub Command1_Click()
Dim a(1 To 6, 1 To 6) As Integer
For i = 1 To 5
For j = 1 To 5
tmp = 99
If i tmp Then
tmp = i
End If
If j tmp Then
tmp = j
End If
If 6 - i tmp Then
tmp = 6 - i
End If
If 6 - j tmp Then
tmp = 6 - j
End If
a(i, j) = tmp
Next j
Next i
For i = 1 To 5
For j = 1 To 5
Picture1.Print Tab(j * 5); a(i, j);
Next j
Picture1.Print
Next i
End Sub
程序输出结果如下:
Private Sub Form_Click()
Dim n, m, i, j, Matrix(), Cache() As Integer
n = CInt(InputBox("请输入矩阵行数N", "矩阵置换"))
m = CInt(InputBox("请输入矩阵列数M", "矩阵置换"))
ReDim Matrix(n - 1, m - 1)
ReDim Cache(m - 1, n - 1)
'录入
For i = 0 To n - 1
For j = 0 To m - 1
Matrix(i, j) = CInt(InputBox("请输入矩阵项(" (i + 1) "," (j + 1) ")", "矩阵置换"))
Next
Next
'转置
For i = 0 To n - 1
For j = 0 To m - 1
Cache(j, i) = Matrix(i, j)
Next
Next
'输出转置前的矩阵
Print "转置前的矩阵为:"
For i = 0 To n - 1
For j = 0 To m - 1
Print Matrix(i, j);
Next
Next
'输出转置后的矩阵
Print "转置后的矩阵为:"
For i = 0 To m - 1
For j = 0 To n - 1
Print Cache(i, j);
Next
Next
End Sub