想添加一个能产生随机数的功能,6位不重复的数字

解决方案 »

  1.   

    radomize; 
    x:=radom(999999);
      

  2.   

    var str: string;
    randomize;
    str:= inttostr(RandomRange(1111111,99999999));
      

  3.   


    function GetRandom(iSize: Integer): string;
    var
      i: Integer;
      iTemp: Integer;
    begin
      i := 0;
      Result := '';
      Randomize;
      while i < iSize do
      begin
        iTemp := Random(10);
        if Pos(IntToStr(iTemp), Result) = 0 then
        begin
          Result := Result + IntToStr(iTemp);
          i := i + 1;
        end;
      end;
    end;
      

  4.   

    function GetRandom(iSize: Integer): string;
    var
      i: Integer;
      iTemp: Integer;
    begin
      i := 0;
      Result := '';
      Randomize;
      while i < iSize do
      begin
        iTemp := Random(10);
        if Pos(IntToStr(iTemp), Result) = 0 then
        begin
          Result := Result + IntToStr(iTemp);
          i := i + 1;
        end;
      end;
    end;
    这个好