[求助]请问怎么实现8位数据对称反转。例:10100000b变为0000101b
我是初学C++的,哪位帮我实现下这个啊。谢谢了,是用堆栈吗
unsigned char revBitsInByte(unsigned char x)
{
x = (x & 0x55) << 1 | (x & 0xAA) >> 1;
x = (x & 0x33) << 2 | (x & 0xCC) >> 2;
x = (x & 0x0F) << 4 | (x & 0xF0) >> 4;
return x;
}