Pagini recente » Cod sursa (job #2361382) | Cod sursa (job #2856246) | Cod sursa (job #2285609) | Cod sursa (job #2100673) | Cod sursa (job #548935)
Cod sursa(job #548935)
var a:array[1..100]of longint;
n,k:longint; f:text;
procedure afis;
var i:longint;
begin
for i:=1 to n do write(f,a[i],' ');writeln(f);
end;
procedure perm(k:longint);
var i,j:longint;
b:boolean;
begin
if k>n then afis else
begin
for i:=1 to n do
begin
b:=true;
for j:=1 to k-1 do
if a[j]=i then begin b:=false; break; end;
if b then begin a[k]:=i; perm(k+1); end;
end;
end;
end;
begin
assign(f,'permutari.in');
reset(f);
readln(f,n);
close(f);
assign(f,'permutari.out');
rewrite(f);
perm(1);
close(f);
end.