public
{ Declarations public }
procedure allkey(chaine: String; maxlen: Integer);
procedure pOut(chaine:String);
var
Form1: TForm1;
dico: string;
cnt,cnt2,maxlen:integer;
stop : boolean;
//
procedure TForm1.allkey(chaine: String; maxlen: Integer);
var i:integer;
begin
if stop then begin
timer1.Enabled:= false;
exit;
end;
If (Length(chaine) < maxlen) Then
For i := 1 To Length(dico) do
allkey(chaine + Midstr(dico, i, 1), maxlen )
Else
If (Length(chaine) = maxlen) Then
pOut (chaine)
end;
procedure TForm1.pOut(chaine: String);
begin
cnt := cnt+1;
application.ProcessMessages;
if (cnt mod 10 = 0) then Memo1.lines.Add('');
Memo1.Lines.Strings[Memo1.Lines.Count-1] := Memo1.Lines.Strings[Memo1.Lines.Count-1] + ' ' + chaine;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
cnt :=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
label1.Caption := inttostr(cnt-cnt2) + ' résultats par secondes';
cnt2 := cnt;
end;
Start :
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
timer1.Enabled:=true;
stop := false;
cnt:=0;
cnt2:=0;
Memo1.Clear;
dico:= Edit1.text;
maxlen:=strtoint(Edit2.text);
for i := 1 to maxlen do
allkey('',i);
end;
Stop :
procedure TForm1.Button2Click(Sender: TObject);
begin
stop :=true;
end;
Keine Kommentare:
Kommentar veröffentlichen