作业帮 > 综合 > 作业

vb编程利用随机数生成两个矩阵(数据不一定相同,前者范围为30~90,后者为101~135) 要求 1.将两个矩阵结果放

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/12 08:52:40
vb编程利用随机数生成两个矩阵(数据不一定相同,前者范围为30~90,后者为101~135) 要求 1.将两个矩阵结果放入C矩阵中 2.将A矩阵转置 3.求C矩阵中元素的最大值和下标 4.以下三角形式显示A矩阵,上三角形式显示B矩阵 5.将A矩阵第1行与第三行对应元素交换位置,即第一行元素放到第三行,第三行元素放到第一行 6.求A矩阵两条对角线元素之和 7.将A矩阵按列的次序把各元素放入一维数组D中,显示结果
vb编程利用随机数生成两个矩阵(数据不一定相同,前者范围为30~90,后者为101~135) 要求 1.将两个矩阵结果放
Option Explicit
Sub SShow(A() As Integer)
Dim I, J
For I = 1 To 4
For J = 1 To 4
Print A(I, J);
Next
Print
Next
End Sub
Private Sub Form_Click()
Dim A(1 To 4, 1 To 4) As Integer
Dim B(1 To 4, 1 To 4) As Integer
Dim I As Integer, J As Integer, T As Integer
Dim L As Integer, U As Integer
L = 30
U = 70
Randomize
For I = 1 To 4
For J = 1 To 4
A(I, J) = Int((U - L + 1) * Rnd + L)
Next
Next
L = 101
U = 135
Randomize
For I = 1 To 4
For J = 1 To 4
B(I, J) = Int((U - L + 1) * Rnd + L)
Next
Next
Print "A:"
SShow A
Print "B:"
SShow B
Dim C(1 To 4, 1 To 4) As Integer
For I = 1 To 4
For J = 1 To 4
C(I, J) = A(I, J) + B(I, J)
Next
Next
Print "C:"
SShow C
For I = 1 To 4
For J = I To 4
T = A(I, J): A(I, J) = A(J, I): A(J, I) = T
Next
Next
Print "A':"
SShow A
Dim R1, C1, Max
Max = C(1, 1)
For I = 1 To 4
For J = 1 To 4
If Max < C(I, J) Then
Max = C(I, J)
R1 = I
C1 = J
End If
Next
Next
Print "C: MAX=" & Max & " 行:" & R1 & " 列:" & C1
Print "A:"
For I = 1 To 4
For J = 1 To I
Print A(I, J);
Next
Print
Next
Print "B:"
For I = 1 To 4
Print Space((I - 1) * 5);
For J = I To 4
Print B(I, J);
Next
Print
Next
For J = 1 To 4
T = B(1, J): B(1, J) = B(3, J): B(3, J) = T
Next
Print "B:"
SShow B
End Sub
这个问题你可以去搜索一下编,程,回,忆,录,之unity3d.零基础开始学起,就算是菜鸟都能看懂
再问: 多谢啦