随机生成25个两位数,构成一个5*5二维数组。在靠边元素及对角元素中求出最大值最小值并显示结果的V

2024-12-01 03:30:35
推荐回答(1个)
回答1:

Private Sub Form_Click()
Dim a(1 To 5, 1 To 5), t%, r%, c%, max%, min%
max = 10: min = 99
For r = 1 To 5
For c = 1 To 5
Randomize
t = Int(Rnd * 90) + 10
a(r, c) = t
Print a(r, c);
If r = 1 Or r = 5 Or c = 1 Or c = 5 Or r = c Then
If t > max Then max = t
If t < min Then min = t
End If
Next c
Print
Next r
Print "Max: "; max
Print "Min: "; min
End Sub