Pagini recente » Cod sursa (job #3177425) | Cod sursa (job #694143) | Cod sursa (job #1298665) | Cod sursa (job #1003779) | Cod sursa (job #322766)
Cod sursa(job #322766)
Program P1;
var n : longint;
s : array[1..10] of longint;
f,g : text;
Procedure permut(k : longint);
var i,j : longint;
ok : boolean;
begin
if k=n then begin
for i:=1 to n do write(g,s[i]);
writeln(g);
end
else
begin
for i:=1 to n do begin
begin
ok:=true;
for j:=1 to k do
if s[j]=i then
begin
ok:=false;
break;
end;
if ok then
begin
s[k+1]:=i;
permut(k+1);
end;
end;
end;
end;
end;
begin
assign(f,'permutari.in');
reset(f);
readln(f,n);
close(f);
assign(g,'permutari.out');
rewrite(g);
permut(0);
close(g);
end.