Go基础_1_8 逻辑运算符
Tutorial: Go初级
Category: Go
Published: 2026-04-07 13:58:26
Views: 21
Likes: 0
Comments: 0
package main
import "fmt"
func main() {
f1 := true
f2 := false
f3 := true
res1 := f1 && f2
fmt.Printf("res1: %t\n", res1)
res2 := f1 && f2 && f3
fmt.Printf("res2: %t\n", res2)
res3 := f1 || f2
fmt.Printf("res3: %t\n", res3)
res4 := f1 || f2 || f3
fmt.Printf("res4: %t\n", res4)
fmt.Println(false || false || false)
fmt.Printf("f1:%t,!f1:%t\n", f1, !f1)
fmt.Printf("f2:%t,!f2:%t\n", f2, !f2)
a := 3
b := 2
c := 5
res5 := a > b && c%a == b && a < (c/b)
fmt.Println(res5)
res6 := b*2 < c || a/b != 0 || c/a > b
fmt.Println(res6)
res7 := !(c/a == b)
fmt.Println(res7)
}