Einzelnen Beitrag anzeigen

Satty67

Registriert seit: 24. Feb 2007
Ort: Baden
1.566 Beiträge
 
Delphi 2007 Professional
 
#17

AW: Effiziente Erzeugung, nicht gleicher Zufallszahlen

  Alt 11. Mai 2011, 10:43
Zitat von s.h.a.r.k:
Delphi-Quellcode:
for i := Length(IntArray) - 1 downto 1 do
  Swap(i, Random(i + 1) + Low(IntArray)));
Zitat von FredlFesl:
Delphi-Quellcode:
For i := Length(A)-1 downto 0 do
begin
  j := Random (i + 1); // 0 <= j <= i
  Swap(i + Low(A), j + Low(A));
end;
Beides mixed exakt identisch. Zwischenspeichern in J kann man sich sparen und downto 1 reicht wohl auch, wie s.h.a.r.k. schon ausgeführt hat.

Geändert von Satty67 (11. Mai 2011 um 10:52 Uhr)
  Mit Zitat antworten Zitat