program Jcombi.nl; conaf tiat&K m ?4<?f typo
cpom - array[1..nmax+lj ot integer var
h, g: tpom;
i, j, k, n> t: integer; bogiń
n:~S? ( liczba el. w zbiorze } 5c:-3; ( liczba el. podzbioru } writeln;
writeln<'Generujemy kombinacje 1, k ' elementów spośród *,n, ’ .
for j:-1 to k do begin
for j:-k+l to n+1 do bogiń gCj] :-0;
ond(for);
t:-k;
h{l]:He+l; i:-0;
whila i<>n+l do bagin
for j:-*1 downto l do write(g[j]:2); writeln;
is-hCU; h(l]:*h[i]; h(i]:-i+i;
if g(i]»l than bogiń
if toO than g[t]:-l-g[t]
alaa gCi-1]:~l-g{i-l];
t:-t+l
and
alaa
bagin
if toi.than gCc-1] :»l-g[t“l] alaa gCi-1];-1-gti-l];
t:“t-l and(i£]; q[
if (t-i-1) or <t-G) than t: “t-ł-1 alaa bagin
t:-t-g(i-l]; hCi-13
if t“0 than h[l};-i-l alsa h(l):“t+1
and(i£>; ondlwhile},-writoln('Koniec.'ł; and.
Generujemy kombinacje 3 elementów spośród 6.
0 |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
G |
1 |
0 |
1 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
1 |
L |
a |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
0 |
0 |
ł |
1 |
i |
0 |
0 |
0 |
1 |
0 |
i |
0 |
0 |
1 |
I |
0 |
i |
0 |
1 |
0 |
1 |
0 |
i |
1 |
0 |
0 |
1 |
0 |
0 |
i_ |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
Koniec. |