ho trovato questo codice interessante,
solo che non so dove mettere una funzione per scrivere su file il risultato
codice:program Tip1032; {$APPTYPE CONSOLE} uses SysUtils; var R, Slen: Integer; procedure P(var A: string; B: string); var J: Word; C, D: string; f:file; begin { P(N,N) >> R=Slen } if Length(B) = SLen - R then begin Write(' {' + A + '} '); {Per++} end else for J := 1 to Length(B) do begin C := B; D := A + C[J]; Delete(C, J, 1); P(D, C); end; end; var Q, S, S2: string; begin S := ' '; S2 := ' '; while (S <> '') and (S2 <> '') do begin Writeln(''); Writeln(''); Write('P(N,R) N=? : '); ReadLn(S); SLen := Length(S); Write('P(N,R) R=? : '); ReadLn(S2); if s2 <> '' then R := StrToInt(S2); Writeln(''); Q := ''; P(Q, S); end; end.


Rispondi quotando