Pagini recente » Cod sursa (job #1926036) | Cod sursa (job #251639) | Cod sursa (job #152810) | Cod sursa (job #1163349) | Cod sursa (job #1747418)
type tablou=array [1..18]of 0..19 ;
var t:tablou;
i,k,m,n:integer;
f,g:text;
b,boo:boolean;
begin
assign(f,'combinari.in');
assign(g,'combinari.out');
reset(f);
rewrite(g);
read(f,n,m);
k:=1;
t[k]:=0;
while k>0 do
begin
repeat
if (t[k]<n)and(k<=m) then begin
b:=true;
t[k]:=t[k]+1;
end
else b:=false;
if b then begin
boo:=true;
if (k>=2)and not(t[k]>t[k-1]) then boo:=false;
end;
until (b and boo) or not(b);
if b then
if k=m then begin
for i:=1 to m do
write(g,t[i],' ');
writeln(g);
end
else begin
k:=k+1;
t[k]:=0;
end
else k:=k-1;
end;
close(f);
close(g);
end.