标签:
Reverse Bits
问题:
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as00111001011110000010100101000000).
他人代码:
public class Solution { public int reverseBits(int n) { int rst = 0; for(int i = 0 ; i < 32; i++) { if( (n&(0x00000001<<i)) !=0) rst |= (0x80000000 >>> i); } return rst; } }
学习之处:
标签:
原文地址:http://www.cnblogs.com/sunshisonghit/p/4337592.html