This commit is contained in:
2025-12-06 17:52:26 +08:00
parent 6bd20511f7
commit 65a2f34b7e
2 changed files with 84 additions and 0 deletions

30
8.switch语句.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"fmt"
)
func main() {
switch_()
}
func switch_() {
var age int
fmt.Println("请输入你的年龄")
fmt.Scan(&age)
switch {
case age <= 0:
fmt.Println("你唬谁呢!!!")
case age <= 17:
fmt.Println("我不信!!!")
case age <= 20:
fmt.Println("里边请!!!")
fallthrough //  继续执行代码
case age <= 35:
fmt.Println("里边请!!!")
}
// 第二种用法
//var week int
}