在不添加临时变量的前提下,交换两个数。
1 a = 10 2 b = 20 3 a,b = b,a 4 print(a,b)
1 a = 10 2 b = 20 3 a = a + b 4 b = a - b 5 a = a - b 6 7 print(a,b)
1 a = 10 2 b = 20 3 a = a ^ b 4 b = a ^ b 5 a = a ^ b 6 print(a,b)