5.6---交换整数的奇数位和偶数位(CC150)
这道题要利用101010来&。
如下答案:
public class Exchange { public int exchangeOddEven(int x) { // write code here int res =(((x & 0x55555555)<<1) | ((x & 0xaaaaaaaa)>>1)); return res; } }
这道题要利用101010来&。
如下答案:
public class Exchange { public int exchangeOddEven(int x) { // write code here int res =(((x & 0x55555555)<<1) | ((x & 0xaaaaaaaa)>>1)); return res; } }