题目

很简单的位运算题目

class Solution {
public:
    uint32_t reverseBits(uint32_t n) {
        
        uint32_t ans;
        
        int pos = 0;
        while(pos<=31)
        {
            ans <<= 1;
            ans |= (n&1);
            n >>=1;
            pos++;
        }
        
        return ans;
        
    }
};

相关文章:

  • 2021-06-08
  • 2022-02-05
  • 2021-08-08
  • 2021-12-28
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2021-06-24
  • 2021-12-11
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案