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/07/06 13:02:39
![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](/uploads/image/z/7113755-11-5.jpg?t=VB+%E9%BA%BB%E7%83%A6%E6%8A%8AA%E7%9F%A9%E9%98%B5%E6%94%B9%E6%88%90%E4%B8%8B%E4%B8%89%E8%A7%92%E5%9E%8B%E6%98%BE%E7%A4%BA%2CB%E4%B8%8A%E4%B8%89%E8%A7%92%E5%9E%8B%E6%98%BE%E7%A4%BAPrivate+Sub+Command1_Click%28%29Dim+a%284%2C+4%29+As+IntegerDim+i+As+Integer%2C+j+As+Integer+For+i+%3D+1+To+4+++For+j+%3D+1+To+4++++a%28i%2C+j%29+%3D+Int%28Rnd+%2A+41+%2B+30%29++++Print+a%28i%2C+j%29%3B+++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
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