Pagini recente » Cod sursa (job #2685943) | Cod sursa (job #201376) | Cod sursa (job #530006) | Cod sursa (job #3191574) | Cod sursa (job #144927)
Cod sursa(job #144927)
var st:array[1..10] of byte;
n:byte;
f:text;
function valid(p:byte):boolean;
var i:byte;
begin
i:=1;
while (i<p) and (st[i]<>st[p]) do inc(i);
valid:=i=p;
end;
procedure scrie;
var i:byte;
begin
for i:=1 to n do write(f,st[i],' ');
writeln(f);
end;
procedure back(p:byte);
var i:byte;
begin
for i:=1 to n do
begin
st[p]:=i;
if valid(p) then
if p=n then scrie
else back(p+1);
end;
end;
begin
assign(f,'permutari.in');
reset(f);
read(f,n);
close(f);
assign(f,'permutari.out');
rewrite(f);
back(1);
close(f);
end.