在VB中如何从1到100任意选25个数放入5*5的二维数组?
展开全部
Private Sub Command1_Click()
' 一维
Dim mArr%(1 To 25), i%
For i = 1 To 25
Randomize
mArr(i) = Int(Rnd * 101) + 100
Print mArr(i),
If i Mod 5 = 0 Then Print
Next i
End Sub
Private Sub Command2_Click()
'二维
Dim mArr2(1 To 5, 1 To 5), r%, c%
For r = 1 To 5
For c = 1 To 5
Randomize
mArr2(r, c) = Int(Rnd * 101) + 100
Print mArr2(r, c),
Next c
Print
Next r
End Sub
' 一维
Dim mArr%(1 To 25), i%
For i = 1 To 25
Randomize
mArr(i) = Int(Rnd * 101) + 100
Print mArr(i),
If i Mod 5 = 0 Then Print
Next i
End Sub
Private Sub Command2_Click()
'二维
Dim mArr2(1 To 5, 1 To 5), r%, c%
For r = 1 To 5
For c = 1 To 5
Randomize
mArr2(r, c) = Int(Rnd * 101) + 100
Print mArr2(r, c),
Next c
Next r
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询