Pagini recente » Cod sursa (job #689174) | Cod sursa (job #3295256) | Cod sursa (job #655341) | Cod sursa (job #3159215) | Cod sursa (job #508556)
Cod sursa(job #508556)
var sol,a:array [1..100] of longint;
k, i, n: longint;
function ok(k: longint): boolean;
begin
ok:=true;
for i:=1 to k-1 do begin
if sol[k]=sol[i] then ok:=false;
end;
end;
procedure afis ;
begin
for i:=1 to n do
write(sol[i],' ');
writeln;
end;
begin
assign (input,'permutari.in'); reset (input);
assign (output,'permutari.out'); rewrite (output);
read (n);
k:=1;
sol[1]:=0;
while k>0 do begin
if sol[k]<n then begin
inc (sol[k]);
if ok(k) then begin
if k=n then afis
else begin inc(k); sol[k]:=0;
end;
end
end
else dec(k);
end;
close (output);
end.