package main
import (
"fmt"
)
func main() {
// 流程控制语句
a := 10
if a < 10{
fmt.Println("small")
} else if a >= 10 && a < 20 {
if a%10 == 0 {
fmt.Printf("0 \n")
}
fmt.Println("mid")
} else {
fmt.Println("big")
}
var grade string = "B"
var marks int = 90
switch marks {
case 90: grade = "A"
case 80: grade = "B"
case 50,60,70: grade = "C"
default: grade = "D"
}
switch grade {
case "A":
fmt.Println("优秀",marks)
case "B":
fmt.Println("良好")
case "C":
fmt.Println("及格")
default:
fmt.Println("差")
}
var x interface{}
switch i := x.(type) {
case nil:
fmt.Println("x的类型:nil",i)
case int:
fmt.Println("x的类型:int")
case float64:
fmt.Println("x的类型:float64")
case string:
fmt.Println("x的类型:string")
default:
fmt.Println("x的类型:others")
}
}