上传
This commit is contained in:
30
8.switch语句.go
Normal file
30
8.switch语句.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user