还可以化简。而且王姑娘上面代码存在一个问题,对0取反时万哥希望得到什么结果?
程序代码:

unsigned int rev(unsigned int x) { unsigned int i; for(i = 1; i && i <= x; i <<= 1); return x ^ i - 1; }请注意我的循环条件

重剑无锋,大巧不工