#include<iostream> #include<stdint.h> using namespace std; class Solution { public: uint32_t reverseBits(uint32_t n) { uint32_t sum = 0; uint32_t mask = 1; int count = 32; while (count>0){ uint32_t temp = (n&mask); //获取最低位 sum = (sum << 1) + temp; //反转 n >>= 1; --count; } return sum; } }; int main(){ Solution solution; cout << solution.reverseBits(43261596) << endl; system("pause"); return 0; }