26 lines
401 B
Go
26 lines
401 B
Go
|
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)
|
||
|
}
|
||
|
}
|