Пример #1
0
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;
}
Пример #2
0
int main(void)
{
	unsigned int numbers[] = {0, 1, 2, 3};
	const size_t n = sizeof(numbers) / sizeof(unsigned int);
	
	do {
		MBprint_array(numbers, n, stdout);
		putchar('\n');
	} while (MBnext_permutation(numbers, n));

	return 0;
}
Пример #3
0
int main(void)
{
	unsigned int numbers[] = {0, 1, 2, 3};
	char *elements[] = {"a", "b", "c", "d"};
	const size_t n = sizeof(numbers) / sizeof(unsigned int);
	
	do {
		MBprint_set(numbers, n, (void*)elements, "[]", (MBprintfn)fputs, stdout);
		putchar('\n');
	} while (MBnext_permutation(numbers, n));

	return 0;
}