zoukankan      html  css  js  c++  java
  • delphi 分享三个随机字符串

    uses math;
    
    function GenID:String;
    var
    b, x: byte;
    begin
      Result := '{';
      Randomize;
      for b:= 1 to 8 do
      begin
        if Random(100) > 50 then Result := Result + chr(RandomRange(48,57))
        else Result := Result + chr(RandomRange(65,90));
      end;
      Result := Result + '-';
      for x:= 1 to 3 do
      begin
        for b:= 1 to 4 do
        begin
          if Random(100) < 50 then Result := Result + chr(RandomRange(48,57))
          else Result := Result + chr(RandomRange(65,90));
        end;
        Result := Result + '-';
      end;
      for b:= 1 to 12 do
      begin
        if Random(100) < 50 then Result := Result + chr(RandomRange(48,57))
        else Result := Result + chr(RandomRange(65,90));
      end;
      Result := Result + '}';
    end;
    
    function genkey :string;
    const
      Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    var
      S: string;
      i, N: integer;
    begin
      Randomize;
      S := '';
      for i := 1 to 30 do begin
        N := Random(Length(Chars)) + 1;
        S := S + Chars[N];
      end;
      result := S;
    end;
    
    function genkey2(c:integer) :string;
    const
      Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    var
      S: string;
      i, N: integer;
    begin
      if c < 20 then c := 30;
      Randomize;
      S := '';
      for i := 1 to c do begin
        N := Random(Length(Chars)) + 1;
        S := S + Chars[N];
      end;
      result := S;
    end;
    
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    memo1.Lines.Add(GenID);
    memo1.Lines.Add(genkey);
    memo1.Lines.Add(genkey2(10));
    end;
  • 相关阅读:
    自适应兄弟元素一起增加高度
    replace小坑位一个
    word-wrap: break-word word-break: break-all;
    1473B. String LCM
    A. Special Permutation(水题)
    B. BerSU Ball(贪心)
    A. Regular Bracket Sequence(水题)
    B. Strange List(数学题)
    C. Move Brackets(水题)
    A. Flipping Game(暴力求法)
  • 原文地址:https://www.cnblogs.com/westsoft/p/8449594.html
Copyright © 2011-2022 走看看