Pagini recente » Cod sursa (job #2178077) | Cod sursa (job #145076) | Cod sursa (job #1106301) | Cod sursa (job #255949) | Cod sursa (job #670352)
Cod sursa(job #670352)
Program PermutBack; Uses Crt;
var n:byte;
st:array[1..10] of byte;
F,G:text;
procedure Print;
var i:byte;
begin
for i:=1 to n do write(G, st[i],' ');
writeln(G);
end;
procedure Perm(k:byte);
var i,j:byte; B:boolean;
begin
if k=n+1 then Print
else
for i:=1 to n do begin
B:=True;
for j:=1 to k-1 do
if st[j]=i then B:=False;
if B then
begin
st[k]:=i;
Perm(k+1);
end;
end;
end;
Begin
assign(F, 'permutari.in');
reset(F);
assign(G, 'permutari.out');
rewrite(G);
readln(F, n);
Perm(1);
close(F);
close(G);
end.