Cod sursa(job #387211)
Utilizator | Moldovan Marcel mimarcel | Data | 27 ianuarie 2010 08:11:42 |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
var s:array[0..18]of byte;
n,k,i:byte;
procedure afsol;
begin
for i:=1 to k-1 do write(s[i],' ');
writeln(s[k]);
end;
procedure back(p:byte);
var val:byte;
begin
if p>n then exit;
for val:=s[p-1]+1 to n do
begin
s[p]:=val;
if p=k then afsol
else back(p+1);
end;
end;
begin
assign(input,'combinari.in');
reset(input);
assign(output,'combinari.out');
rewrite(output);
read(n,k);
fillchar(s,sizeof(s),0);
back(1);
close(input);
close(output);
end.