Pagini recente » Cod sursa (job #2488420) | Cod sursa (job #2729813) | Cod sursa (job #636801) | Cod sursa (job #2036576) | Cod sursa (job #663532)
Cod sursa(job #663532)
var p,n,i:integer;
a:array[1..100] of integer;
ok:boolean;
f,g:text;
begin
assign(f,'permutari.in'); reset(f);
assign(g,'permutari.out'); rewrite(g);
read (f,n);
p:=1;
while p>0 do
begin a[p]:=a[p]+1;
ok:=false;
for i:=1 to p-1 do
if a[i]=a[p] then ok:=true;
if a[p]>n then begin a[p]:=0;
p:=p-1;
end
else if (p=n) and (ok=false) then begin for i:=1 to p do
write (g,a[i],' ');
writeln(g);
end
else if (ok=false) then p:=p+1;
end;
close(f);
close (g);
end.