0xaaaaaaaa = 10101010101010101010101010101010-------------------偶数位为1,奇数位为0
0x55555555 = 1010101010101010101010101010101 --------------------偶数位为0,奇数位为1
0x33333333 = 110011001100110011001100110011 ------------------------1和0每隔两位交替出现
0xcccccccc = 11001100110011001100110011001100-----------------------0和1每隔两位交替出现
0x0f0f0f0f = 00001111000011110000111100001111 -------------------------1和0每隔四位交替出现
0xf0f0f0f0 = 11110000111100001111000011110000 -------------------------0和1每隔四位交替出现
0x01010101 = 1000000010000000100000001 -------------------------------先来个1,接着7个0和一个1交替出现。
((x >> 1) & 0x55555555); --- 先右移一位,等于拿到奇数位
((x & 0x55555555) << 1 --- 奇数位移到偶数位
太神奇了!!!!!!
有时候CSP初赛会考的,这个要记啊啊啊啊啊!!!