Pagini recente » Cod sursa (job #289944) | Diferente pentru documentatie/textile intre reviziile 107 si 27 | Cod sursa (job #1352617) | Cod sursa (job #402866) | Cod sursa (job #208876)
Cod sursa(job #208876)
program pascal;
var n,k,i:longint;
sol:array[1..9] of integer;
f,g:text;
function count(k:integer):boolean;
begin
count:=true;
for i:=1 to k-1 do
if sol[k]=sol[i] then
begin
count:=false;
break;
end;
end;
procedure tipar;
begin
for i:=1 to n do write(g,sol[i],' ');
writeln(g);
end;
procedure bkt;
begin
k:=1;
sol[1]:=0;
while k>0 do
if sol[k]<n then
begin
sol[k]:=sol[k]+1;
if count(k) then
if k=n then tipar
else
begin
k:=k+1;
sol[k]:=0;
end
end
else k:=k-1;
end;
begin
assign(f,'permutari.in'); reset(f);
assign(g,'permutari.out'); rewrite(g);
read(f,n);
bkt;
close(f);
close(g);
end.