Implementation does not use an intermediate variable exchange value of the two numbers (Golang Programming classic case) with the Go language

There are two variables, a and B, which requires the exchange, but does not allow the use of an intermediate variable, the final print.

package main

import (
	"fmt"
)

func main() {
	var a int  = 10
	var b int  = 20
	
	a = a + b
	b = a - b
	a = a - b

	fmt.Printf("a=%v b=%v", a, b)
}

Execution results as shown below:
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/cui_yonghua/article/details/93630081