#交换两个变量
#1
a = 20
b = 15
c = a
a = b
b = c
print(a,b)
#2
a = 20
b = 15
a = a + b
b = a - b
a = a - b
print(a,b)
#3异或运算
a = 20
b = 15
a = a ^ b
b = a ^ b
a = a ^ b
print(a,b)
#python
a = 20
b = 15
a,b = b,a
print(a,b)
#交换两个变量
#1
a = 20
b = 15
c = a
a = b
b = c
print(a,b)
#2
a = 20
b = 15
a = a + b
b = a - b
a = a - b
print(a,b)
#3异或运算
a = 20
b = 15
a = a ^ b
b = a ^ b
a = a ^ b
print(a,b)
#python
a = 20
b = 15
a,b = b,a
print(a,b)
本文标题:交换两个数据
本文链接:https://www.haomeiwen.com/subject/gcylgktx.html
网友评论