git.samba.org
/
tridge
/
junkcode.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
better handling of whole files
[tridge/junkcode.git]
/
permute.c
1
#include <stdio.h>
2
3
typedef unsigned long long uint64;
4
5
printbits(uint64 x)
6
{
7
int i;
8
for (i=0;i<64;i++) {
9
if (x & (((uint64)1)<<i)) {
10
printf("%d ", i);
11
}
12
}
13
printf("\n");
14
}
15
16
void permute(int n)
17
{
18
uint64 x=0;
19
20
if (n == 0) return;
21
22
do {
23
x++;
24
printbits(x);
25
} while (x != ((1<<n)-1));
26
}
27
28
29
int main(int argc, char *argv[])
30
{
31
permute(atoi(argv[1]));
32
return 0;
33
}