Pagini recente » Cod sursa (job #248590) | Cod sursa (job #465984) | Cod sursa (job #1023171) | Cod sursa (job #699014) | Cod sursa (job #670351)
Cod sursa(job #670351)
Program PermutBack; Uses Crt;
var n:byte; m:integer;
st:array[1..10] of byte;
F,G:text;
procedure Print;
var i:byte;
begin
m:=m+1;
write('{');
for i:=1 to n-1 do write(st[i],',');
write(G, st[n],'}');
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.