unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,perm,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var p: TPermutation;
    i:integer;
    s:string;
begin
  SetLength(p,length(edit1.text));
  for i:=1 to length(edit1.text) do
    p[i-1]:=ord(Edit1.Text[i]);

    memo1.Clear;
    memo1.lines.add('');

  repeat
    s:='';
    for i:=0 to high(p) do begin
      s:=s+chr(p[i]);
      memo1.lines.add(s);
    end;
  until not  nextPermutation(p);

  tstringlist(memo1.lines).sort;
end;

end.
