Algorithms that generate non-repeated random numbers can solve problems such as random shuffling and lottery. Some algorithms on the Internet are more conscious and traditional, and simple algorithms are now provided. The following source program contains 36 numbers, which are randomly arranged to generate random numbers that are not repeated.
VaR
AA: array [1 .. 36] of string [2]; // The AA array is an array to be randomly arranged,
{Assign values to the AA array in sequence for 1 .. 36 First}
Procedure tform1.formcreate (Sender: tobject );
VaR
I: integer;
Begin
For I: = 1 to 36 do begin
AA [I]: = inttostr (I );
Bb [I]: = inttostr (I );
End;
End;
{Random sorting}
Procedure tform1.button1click (Sender: tobject );
VaR
I, J: integer;
Swapa: String [2];
Begin
Randomize;
For I: = 1 to 36 do begin
J: = 1 + random (36 );
Swapa: = AA [I];
AA [I]: = AA [J];
AA [J]: = swapa;
End; // random numbers that are not repeated