Pagini recente » Cod sursa (job #1076253) | Cod sursa (job #2030972) | Cod sursa (job #1211830) | Cod sursa (job #1239872) | Cod sursa (job #2428928)
var t:array[0..20] of integer;
n,m,k,i,p:integer;
procedure tipar;
begin
for i:=1 to m do write(t[i],' ');
writeln
end;
procedure succ;
begin
if t[k]<n then
begin
inc(t[k]);
p:=1
end
else p:=0;
end;
begin
assign(input,'combinari.in'); reset(input);
assign(output,'combinari.out'); rewrite(output);
readln(n,m);
k:=1; t[k]:=0;
while k>0 do
begin
succ;
if p=1 then
if k=m then tipar else
begin
inc(k);
t[k]:=t[k-1]
end
else dec(k)
end;
close(input);
close(output)
end.