左移右移的能够使得数字*2或者/2

那*3怎么办,就左移一位然后再+

经典面试题:

1.交换2个数,不用temp   a=10  b=12

1.1

a = a + b = 22

b = a - b = 10

a = a - b =10

1.2 位运算  ^(异或)

a=1010  b = 1100

a = a ^ b =0110

b = a ^ b =1010

a = a ^ b = 1100

04-17 21:29