int MBnext_k_permutation(int *ar, int n, int k) { int result = MBnext_permutation(ar, k); if (result == 0) { result = MBnext_combination(ar, n, k); } return result; }
int main(void) { unsigned int numbers[] = {0, 1, 2}; const size_t k = sizeof(numbers) / sizeof(unsigned int); unsigned int n = 5; do { MBprint_array(numbers, k, stdout); putchar('\n'); } while (MBnext_combination(numbers, n, k)); return 0; }