package mainimport "fmt"func main () { var i, j int = 1, 2 //并行赋值 fmt.Println(i, j) p := &i h := &j swap(p, h) fmt.Println(i, j)}func swap(num1 *int, num2 *int) { temp := *num1 //值交换,而不是指针交换 *num1 = *num2 *num2 = temp} 1 22 1