Pagini recente » Cod sursa (job #1388695) | Cod sursa (job #3199777) | Cod sursa (job #2694735) | Cod sursa (job #1030927) | Cod sursa (job #663533)
Cod sursa(job #663533)
var n,k,j,p:integer;
a:array[1..100] of integer;
f,g:text;
ok:boolean;
begin
assign(f,'combinari.in'); reset(f);
assign(g,'combinari.out'); rewrite (g);
read (f,n,k);
p:=1;
while p>0 do
begin a[p]:=a[p]+1;
ok:=false;
for j:=1 to p-1 do
if a[j]>=a[j+1] then ok:=true;
if a[p]>n then begin a[p]:=0;
p:=p-1;
end
else if (p=k) and (ok=false) then begin for j:=1 to p do
write (g,a[j],' ');
writeln(g);
end
else if (ok=false) then p:=p+1;
end;
close (f);
close (g);
end.