procedure ShuffleInt(var IntArr: TIntArray; Num: integer); var i,k,m:integer; begin Randomize; for i := 1 to Num do IntArr[i] := i; for i := Num downto 1 do begin k := Random(i-1)+1; m := IntArr[i]; IntArr[i] := IntArr[k]; IntArr[k] := m; end; end;
procedure TForm1.Button1Click(Sender: TObject); var ss1,ss2:WideString; IntArr:TIntArray; i:integer; begin ss1 := Edit1.Text; ShuffleInt(IntArr,Length(ss1)); SetLength(ss2,Length(ss1)); for i := 1 to Length(ss1) do ss2[i] := ss1[IntArr[i]]; Edit2.Text := ss2; end;