VB 麻烦把A矩阵改成下三角型显示,B上三角型显示Private Sub Command1_Click()Dim a(4, 4) As IntegerDim i As Integer, j As Integer For i = 1 To 4 For j = 1 To 4 a(i, j) = Int(Rnd * 41 + 30) Print a(i, j); Next j Print Next i
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 18:01:27
VB 麻烦把A矩阵改成下三角型显示,B上三角型显示Private Sub Command1_Click()Dim a(4, 4) As IntegerDim i As Integer, j As Integer For i = 1 To 4 For j = 1 To 4 a(i, j) = Int(Rnd * 41 + 30) Print a(i, j); Next j Print Next i
VB 麻烦把A矩阵改成下三角型显示,B上三角型显示
Private Sub Command1_Click()
Dim a(4, 4) As Integer
Dim i As Integer, j As Integer
For i = 1 To 4
For j = 1 To 4
a(i, j) = Int(Rnd * 41 + 30)
Print a(i, j);
Next j
Print
Next i
Print
Dim b(4, 4) As Integer
For i = 1 To 4
For j = 1 To 4
b(i, j) = Int(Rnd * 34 + 101)
Print b(i, j);
Next j
Print
Next i
VB 麻烦把A矩阵改成下三角型显示,B上三角型显示Private Sub Command1_Click()Dim a(4, 4) As IntegerDim i As Integer, j As Integer For i = 1 To 4 For j = 1 To 4 a(i, j) = Int(Rnd * 41 + 30) Print a(i, j); Next j Print Next i
Private Sub Command1_Click()
Dim a(4,4) As Integer
Dim i As Integer,j As Integer
For i = 1 To 4
For j = i To 4
a(i,j) = Int(Rnd * 41 + 30)
Print a(i,j);
Next j
Print
Next i
Print
Dim b(4,4) As Integer
For i = 1 To 4
For j = 1 To i
b(i,j) = Int(Rnd * 34 + 101)
Print b(i,j);
Next j
Print
Next i
End Sub
或者将程序写成下面的形式,用空格占位,使A的数据输出位置更加直观
Private Sub Command1_Click()
Dim a(4,4) As Integer
Dim i As Integer,j As Integer
For i = 1 To 4
For j = 1 To i - 1 '输出空格使数字在上三角的位置上
Print Spc(4);
Next j
For j = i To 4
a(i,j) = Int(Rnd * 41 + 30)
Print a(i,j);
Next j
Print
Next i
Print
Dim b(4,4) As Integer
For i = 1 To 4
For j = 1 To i
b(i,j) = Int(Rnd * 34 + 101)
Print b(i,j);
Next j
Print
Next i
End Sub