#include <stdio.h>
int arr[10];
void dfs(int n, int r, int sz) {
for (int i = n; i >= r; i--) {
arr[r - 1] = i-1;
if (r > 1) {
dfs(i - 1, r - 1, sz);
}
else {
for (int i = 0; i < sz; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
}
}
int main()
{
dfs(6, 4, 4);
return 0;
}
https://helloacm.com/cc-coding-exercise-recursive-combination-algorithm-implementation/