每次取最低位 加在中间结果的上面 然后把中间结果左移一位 除了最后一次不用左移
public class Solution {
// you need treat n as an unsigned value
public int reverseBits(int n) {
int res = 0;
for ( int i = 1; i <= 32; i ++ ){
res += n & 1;
n >>>= 1;
if ( i <= 31 )
res <<= 1;
}
return res;
}
}