30 lines
452 B
Go
30 lines
452 B
Go
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
|
|
} |