https://github.com/rdbo/universal-combinations
Universal Combinations Algorithm in C
https://github.com/rdbo/universal-combinations
Last synced: 11 months ago
JSON representation
Universal Combinations Algorithm in C
- Host: GitHub
- URL: https://github.com/rdbo/universal-combinations
- Owner: rdbo
- Created: 2021-11-11T00:00:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-11T00:02:34.000Z (over 4 years ago)
- Last Synced: 2025-07-21T05:42:40.835Z (about 1 year ago)
- Language: C
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Universal Combinations Algorithm in C
```c
int main()
{
char carr[] = { 'a', 'b', 'c', 'd' };
int iarr[] = { 1, 2, 3, 4, 5, 6, 7 };
size_t n;
n = 2;
combinations(carr, ITEMSIZE(carr), ARRLEN(carr), n, callback_char, (void *)&n);
printf("--------------------\n");
n = 6;
combinations(iarr, ITEMSIZE(iarr), ARRLEN(iarr), n, callback_int, (void *)&n);
return 0;
}
```
Result:
```
{ 'a' 'b' }
{ 'a' 'c' }
{ 'a' 'd' }
{ 'b' 'c' }
{ 'b' 'd' }
{ 'c' 'd' }
--------------------
{ 1 2 3 4 5 6 }
{ 1 2 3 4 5 7 }
{ 1 2 3 4 6 7 }
{ 1 2 3 5 6 7 }
{ 1 2 4 5 6 7 }
{ 1 3 4 5 6 7 }
{ 2 3 4 5 6 7 }
```