golang 交换两个变量的值,不允许有中间变量
package mainimport ( "fmt" _"unsafe")func main(){ //交换两个变量的值,不允许有中间变量 var a int = 100 var b int = 200 a = a + b //替换 a 为 a + b // (b = a - b) ==>(b = a + b - b) ==> (b = a) b = a - b //替换 a = a + b 替换上面b 也就是 a //