if else

if else

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"fmt"
	"math/rand"
)

func main() {
	if true {
		fmt.Println("Condition is true.")
	} else {
		fmt.Println("Condition is false.")
	}

	score := rand.Intn(100)

	if score < 60 {
		fmt.Println("E")
	} else if 60 <= score && score <= 69 {
		fmt.Println("D")
	} else if 70 <= score && score <= 79 {
		fmt.Println("C")
	} else if 80 <= score && score <= 89 {
		fmt.Println("B")
	} else if 90 <= score && score <= 100 {
		fmt.Println("A")
	}
}
最后修改 October 10, 2024: 更新 (a4b8f85)