初始化

This commit is contained in:
2025-04-08 17:01:19 +08:00
commit 4228f447f7
75 changed files with 574 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
module conditionals
go 1.23.5

View File

@@ -0,0 +1,25 @@
package main
import "fmt"
func main() {
score := 85
// if-else条件语句
if score >= 90 {
fmt.Println("优秀")
} else if score >= 80 {
fmt.Println("良好")
} else if score >= 60 {
fmt.Println("及格")
} else {
fmt.Println("不及格")
}
// 带初始化的if语句
if num := 9; num%2 == 0 {
fmt.Printf("%d是偶数\n", num)
} else {
fmt.Printf("%d是奇数\n", num)
}
}