Cod sursa(job #2428928)

Utilizator Arteni_CristiArteni Cristi Arteni_Cristi Data 6 iunie 2019 20:40:36
Problema Combinari Scor 100
Compilator fpc Status done
Runda Arhiva educationala Marime 0.57 kb
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.