所用语言 Java 所用知识 位运算 解题思路 每次循环左移一位,并加上n的最后一位,再把n右移一位 完整代码 int res = 0; for (int i = 0; i < 32; i++) { res=(res<<1)+(n&1); n>>=1; } return res;