短路或与短路与
a == b || a == c
如果a等于b,就不会检测a是否等于c,间接返回true
同理
a == b && a == c
如果a不等于b,也不会检测a是否等于c,间接返回false
除运算
- 1
fmt.Println("9 / 4:",9/4)
fmt.Println("9.0 / 4:",9.0/4)
9 / 4: 2
9.0 / 4: 2.25
-2
不应用两头变量替换两个变量
a = a + b
b = a - b
a = a - b
-3
数组中存在一个独自值,其余都是成对的,怎么找到
arr := []int {1,1,2,2,3,3,4}
temp := 0
for _,v := range arr {
temp ^= v
}
fmt.Println("temp:",temp)
temp: 4
发表回复