# Go 语言学习之运算符

01

func main() {

a := 10

b := 5

fmt.Println("a + b = ", a+b)

fmt.Println("a - b = ", a-b)

fmt.Println("a * b = ", a*b)

fmt.Println("a / b = ", a/b)

fmt.Println("a % b = ", a%b)

}

02
++ 和 —

func main() {

a := 10

b := 5

a++

b--

fmt.Println("a++:", a)

fmt.Println("b--:", b)

03

func main() {

aa := 50

aa += 10

fmt.Println("aa = ", aa)

bb := 50

bb -= 10

fmt.Println("bb = ", bb)

cc := 50

cc *= 10

fmt.Println("cc = ", cc)

dd := 50

dd /= 10

fmt.Println("dd = ", dd)

ff := 50

ff %= 10

fmt.Println("ff = ", ff)

}

04

func main() {

if a > 5 && b > 5 {

fmt.Println("a > 5 且 b > 5")

}

if a > 5 || b > 5 {

fmt.Println("a > 5 或 b > 5")

}

if a > 5 && b >= 5 {

fmt.Println("a > 5 且 b >= 5")

}

if a == b {

fmt.Println("a == b")

}

if a != b {

fmt.Println("a != b")

}

boolean := false

if !boolean {

fmt.Println("非假既真")

}

}

05

06
& 和 *

（*
），不是所有对象都能进行取地址操作，

func main() {

x := 50

y := &x

*y++

z := *y

fmt.Println("y = ", y)

fmt.Println("x = ", x)

fmt.Println("z = ", z)

}

07

08

 >> <=

a + b =  15

a - b =  5

a * b =  50

a / b =  2

a % b =  0

a++: 11

b--: 4

aa =  60

bb =  40

cc =  500

dd =  5

ff =  0

a > 5 或 b > 5

a != b

y =  0xc0000b4070

x =  51

z =  51