Pagini recente » Cod sursa (job #3210938) | Cod sursa (job #1761359) | Cod sursa (job #1428611) | Cod sursa (job #97353) | Cod sursa (job #1195347)
program permutari;
type vector=array [1..8] of byte;
var v:vector;
n:byte;
f,g:text;
function validare(k:byte):boolean;
var i:byte;
begin
validare:=true;
for i:=1 to k-1 do if v[i]=v[k] then validare:=false;
end;
procedure afisare;
var i:byte;
g:text;
begin
assign (g,'permutari.out');
append(g);
for i:=1 to n do write (g,v[i],' ');
writeln(g);
close(g);
end;
procedure back(k:byte);
var i:byte;
begin
for i:=1 to n do begin
v[k]:=i;
if validare(k) then if k=n then afisare
else back(k+1);
end;
end;
begin
assign (f,'permutari.in');
reset(f);
read(f,n);
back(1);
close(f);
end.