Int (Rnd () * 30)
CodePudding user response:
1-30 or 1-50 for the random number of integers only 30 or 50, impossible is never repeatedCodePudding user response:
Since random how can't repeatRecords appeared
CodePudding user response:
A total of 30 to 50 digital, no said "never repeated"?CodePudding user response:
Since it is random, how can have repeat? 1 ~ 30, total can't appear the same number every time?CodePudding user response:
The first number with Rnd () () at the same time as the subsequent seed is calculated;Other several linear congruence with algorithm calculation;
Can guarantee take 30 times just to take a 1 ~ 30 each,
CodePudding user response:
Option Explicit
Private Sub Command1_Click ()
Dim I As an Integer, n As Integer
If List1. ListCount Then
If List1. ListCount & gt; 1 Then
N=Int (Rnd * List1. ListCount)
The Else
N=0
End the If
List2. AddItem List1. List (n)
List1. RemoveItem n
End the If
End Sub
Private Sub Form_Load ()
Dim As Integer I
For I=1 To 30
List1. AddItem I
Next I
List2. Clear
Randomize
End Sub
CodePudding user response:
Google shuffle algorithmCodePudding user response:
Whether to record the front have collect the data???????CodePudding user response:
Is actually a random number from a list, whenever a record in the selected list, it is removed from the list,CodePudding user response:
Dig the grave!Linear congruence to Google:
In addition to write down a value before, don't need the extra storage space, pure algorithm,
CodePudding user response:
is a grave indeed as expectedCodePudding user response:
Cosmic rays just breakdown CSDN server clock,