leetcode-190. 颠倒二进制位-C语言

uint32_t reverseBits(uint32_t n) {
    uint32_t m = 0, i=0;
    uint8_t *bf = (uint8_t *)&m;
    
    while(i<32){
        m |= (n&0x1);
        
        if(i<31)
            m <<= 1;
        
        n = n >> 1;
        i++;
    }
    
    return m;
}

猜你喜欢

转载自blog.csdn.net/weixin_36094222/article/details/92838414
今日推荐