# 方法一
a=1
b=2
print("交换前a=",a,"b=",b)
a,b=b,a
print("交换后a=",a,"b=",b)
# 方法二
a=3
b=4
print("交换前a=",a,"b=",b)
t=a
a=b
b=t
print("交换后a=",a,"b=",b)
# 方法3
a=5
b=6
print("交换前a=",a,"b=",b)
a=a+b
b=a-b
a=a-b
print("交换后a=",a,"b=",b)
# 方法四
# 用异或交换两个元素
a = 5
b = 10
a = a ^ b
b = a ^ b
a = a ^ b
print("a =", a)
print("b =", b)