const m=10;
type ss=set of 1..m;
var s:ss;
i,n:integer;
mas:array[1..m] of integer;
procedure per(var pr:ss; k,j:integer);
var i:integer;
s1:ss;
begin
mas[k]:=j;
s1:=pr-[j];
for i:=1 to n do
if i in s1 then per(s1,k+1,i);
if k=n then begin
for i:=1 to n do write(mas[i]:5);
writeln;
end;
end;
BEGIN
readln(n);
s:=[1..n];
for i:=1 to n do per(s,1,i);
readln;
END.
<< Назад