Öhm, ja ... bilde mir ein eure Beispiele zu verstehen, aber sehe nicht so richtig, wie mir das weiter hilft. Vielleicht doch mal der Code:
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| procedure check(wort:string;nr:integer); begin if (not gefunden) then begin if (wort=pwd) then begin gefunden:=true; showMessage(wort); exit; end else begin if (length(wort)< max) and (not gefunden) then check(wort+Mzeichen[0],0); end;
if (nr<maxnr) and (not gefunden) then begin wort[length(wort)]:=Mzeichen[nr+1]; check(wort,nr+1); end; end; end; |
Dabei ist MZeichen ein Array of char (der Zeichenvorrat) und gefunden eine boolsche Variable.
Ich würde gern die Anzahl der Bedingungen verringern, um die Suchgeschwindigkeit zu erhöhen, aber die Rekursion soll auch sofort abbrechen, wenn das Suchwort gefunden wurde.
MfG C.