编写函数: unsigned int reverse_bit(unsigned int value); 这个函数的返回 值value的二进制位模式从左到右翻转后的值。 如: 在32位机器上25

来源:互联网 发布:超级老师软件 编辑:程序博客网 时间:2024/04/29 09:11
unsigned int  reverse_bit(unsigned int value){int value1 = 0;int count = 31;while (count){int ret=value & 1;value1 ^= ret;value1 <<= 1;value >>= 1;count--;}return value1;}int main(){printf("Please: ");unsigned int value = 0;scanf("%u", &value);unsigned int data = reverse_bit(value);printf("data is : %u\n", data);system("pause");return 0;}

0 0
原创粉丝点击