Thema: Delphi Random-Frage

Einzelnen Beitrag anzeigen

mr_emre_d
(Gast)

n/a Beiträge
 
#9

Re: Random-Frage

  Alt 9. Aug 2008, 16:41
und hier ne function
Code:
function Random(rFrom, rTo: Integer; const rWithOut: Array of Integer ): Integer; overload;
var
  i: Integer;
  nFlag: Boolean;
begin
  repeat
    nFLag := True;
    Result := system.Random( rTo - rFrom + 1 ) + rFrom;
    for i:= low(rWithOut) to high(rWithOut) do
      if Result = integer(rWithOut[i]) then
      begin
        nFlag := False;
        break;
      end;
  until nFlag;
end;

// evt. Auruf:
random( 3, 5, [1,2,3,4] ) );
Wäre vlt. was für die Code-Library ? hehe

  Mit Zitat antworten Zitat