Pagini recente » Cod sursa (job #2343492) | Cod sursa (job #2043353) | Cod sursa (job #2574732) | Cod sursa (job #267037) | Cod sursa (job #871854)
Cod sursa(job #871854)
var a:array[1..8] of byte;
exista:array[1..8] of boolean;
n,i:integer;f,g:text;
procedure afisare;
Begin
for i:=1 to n do
write(g,a[i],' ');
writeln(g);
end;
procedure back(x:integer);
var j:integer;
Begin
If x<=n then
begin
For j:=1 to n do
If exista[j]=false then
Begin
a[x]:=j;
exista[j]:=true;
back(x+1);
exista[j]:=false;
end;
end
else
afisare;
end;
Begin
assign(f,'permutari.in');reset(f);
assign(g,'permutari.out');rewrite(g);
readln(f,n);
back(1);
close(g);
close(f);
end.