Dazu braucht man eine Routine die 4 Zufallszahlen berechnet, zum Beispiel so:
Delphi-Quellcode:
type
TFourIntegers = array [1..4] of integer;
function GetFourRandoms: TFourIntegers;
var
List: TList;
I, Index: integer;
begin
List := TList.Create;
try
for I := 1 to 4 do
List.Add(Pointer(I));
for I := 1 to 4 do
begin
Index := Random(List.Count);
Result[I] := Integer(List[Index]);
List.Delete(Index);
end;
finally
List.Free
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
A: TFourIntegers;
begin
A := GetFourRandoms;
ShowMessage(Format('%d %d %d %d', [A[1], A[2], A[3], A[4]]));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
end;