请教一个 VB 5*5的0-1-100的随机矩阵,不要求重复,在线等...
Private Sub Command1_Click()
Dim s As Integer
Dim t(1 To 25) As Integer
Dim k As Integer
Dim a(0 To 100) As Boolean
For i = 0 To 100
a(i) = True
Next
Randomize
k = 0
Do
s = Int(101 * Rnd)
If a(s) = True Then
k = k + 1
t(k) = s
a(s) = False
End If
Loop While k < 25
For i = 1 To 5
Text1.Text = Text1.Text & t((i - 1) * 5 + 1) & " " & t((i - 1) * 5 + 2) & " " & t((i - 1) * 5 + 3) & " " & t((i - 1) * 5 + 4) & " " & t((i - 1) * 5 + 5) & Chr(13) & Chr(10)
Next i
End Sub
Private Sub Command1_Click()
Dim s As Integer
Dim t(1 To 25) As Integer
Dim k As Integer
Dim a(0 To 100) As Boolean
For i = 0 To 100
a(i) = True
Next
Randomize
k = 0
Do
s = Int(101 * Rnd)
If a(s) = True Then
k = k + 1
t(k) = s
a(s) = False
End If
Loop While k < 25
For i = 1 To 5
Text1.Text = Text1.Text & t((i - 1) * 5 + 1) & " " & t((i - 1) * 5 + 2) & " " & t((i - 1) * 5 + 3) & " " & t((i - 1) * 5 + 4) & " " & t((i - 1) * 5 + 5) & Chr(13) & Chr(10)
Next i
Text1.Text = Text1.Text & Chr(13) & Chr(10) & "*****完毕***********" & Chr(13) & Chr(10)
End Sub