📜  随机播放列表并打印 - Delphi 代码示例

📅  最后修改于: 2022-03-11 14:54:56.542000             🧑  作者: Mango

代码示例2
Function SortIntegerList : String;
var a : Array of cardinal;
    i,j : integer;
      t : cardinal;
 Letter : String[1];
   AStr : String;
begin
// USING the simple Satolo cycle to unsort/scramble a numeric string
// Modified to scramble the letters of the Alphabet
  randomize;
  a := [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];
  i := length(a);
  while i > 0 do
    begin
     dec(i);
     j := randomrange(Low(a),i);
     t := a[i];
     a[i] := a[j];
     a[j] := t;
     Letter := Chr(a[i]+64);
     AStr := AStr + Letter;
    end;
    Result := AStr;
end;

// How to use
Procedure ButtonClick(Sender: TOBject);
begin
  ShowMessage('Scrambled String '+AStr);
end;