#include <stdio.h> #include <math.h> unsigned int reverse_bit(unsigned int value) { int i = 0, sum = 0; int ret; for (i = 0; i < 32; i++) { ret = value & 1; sum = sum + (ret*pow(2, (31 - i))); value = value >> 1; } return sum; } int main() { int num = 0; printf("请输入一个数:\n"); scanf("%d", &num); int ret=reverse_bit(num); printf("%u", ret); return 0; }
时间: 2024-10-06 00:38:54