20 lines
437 B
Plaintext
20 lines
437 B
Plaintext
code ChOut=8, CrLf=9, IntOut=11;
|
|
def M=3, N=5;
|
|
int A(N-1);
|
|
|
|
proc Combos(D, S); \Display all size M combinations of N in sorted order
|
|
int D, S; \depth of recursion, starting value of N
|
|
int I;
|
|
[if D<M then \depth < size
|
|
for I:= S to N-1 do
|
|
[A(D):= I;
|
|
Combos(D+1, I+1);
|
|
]
|
|
else [for I:= 0 to M-1 do
|
|
[IntOut(0, A(I)); ChOut(0, ^ )];
|
|
CrLf(0);
|
|
];
|
|
];
|
|
|
|
Combos(0, 0)
|