矩阵转置vb点虐 代码 n×n矩阵转置c代码
vb矩阵转置
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编程,应用二维数组产生随机矩阵5*5,并实现矩阵的转置。
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
程序输出结果如下:
编写VB程序,实现矩阵转置,即将一个nⅹm的矩阵的行和列互换。
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
文章题目:矩阵转置vb点虐 代码 n×n矩阵转置c代码
分享链接:http://pwwzsj.com/article/ddjeddc.html