Aug 20
Algoritmo permutazioni con ripetizione
program prova2; uses crt; var s : string; stack : string; stack_idx : longint; risposta :string; function estratto(t : string; i : integer) : string; begin delete(t, i, 1); estratto := t; end; procedure scrivi_perm(t : string); var i : integer; begin if length(t) = 0 then begin inc(stack_idx); writeln(stack_idx:5, ') ' + stack); end else for i := 1 to length(t) do begin stack := stack + t[i]; scrivi_perm(estratto(t, i)); stack := copy(stack, 1, length(stack)-1); end; end; begin repeat clrscr; stack := ''; stack_idx := 0; write('parola : '); readln(s); scrivi_perm(s); readln; writeln('Vuoi Continuare?'); readln(risposta); until (risposta<>'s'); end.






























