Pagini recente » Cod sursa (job #896357) | Cod sursa (job #837782) | Cod sursa (job #926504) | Cod sursa (job #2770339) | Cod sursa (job #266529)
Cod sursa(job #266529)
var st:array[1..10] of 0..10;
n,i,p:0..10;
f,g:text;
ok:boolean;
begin
assign(f,'permutari.in');reset(f);
readln(f,n);
close(f);
assign(g,'permutari.out');rewrite(g);
p:=1;
st[p]:=0;
while p>0 do
begin
if st[p]<n then begin
st[p]:=st[p]+1;
ok:=true;
for i:=1 to p-1 do if st[p]=st[i] then ok:=false;
if ok then if p=n then begin
for i:=1 to p do write(g,st[i],' ');
writeln(g);
end
else begin
p:=p+1;
st[p]:=0;
end;
end
else p:=p-1;
end;
close(g);
end.