0 000 000 000 0
1 001 010 100 4
2 010 100 010 2
3 011 110 110 6
4 100 001 001 1
5 101 011 101 5
6 110 101 011 3
7 111 111 111 7
// data: array
// N:size of array
void mirror(char *data, const int N)
{
int target = 0;
for (int position = 0; position< N; position++) {
if (target > position)
swap(data[position], data[target];
int Mask = N;
while (target & Mask >>= 1){
// unset
target &= ~Mask;
}
target |= Mask;
}
}
bits mirror
Mar062009
Subscribe to:
Post Comments (Atom)
0 评论: (+add yours?)
Post a Comment