for循环
This commit is contained in:
32
main.go
32
main.go
@@ -3,32 +3,10 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
score := 87
|
// for循环输出
|
||||||
switch score / 10 {
|
// 循环次数i1 < 10
|
||||||
case 10:
|
for i1 := 0; i1 < 10; i1++ {
|
||||||
fmt.Println("You are 10%")
|
fmt.Println("循环第", i1+1, "次")
|
||||||
case 9:
|
|
||||||
fmt.Println("You are 9%")
|
|
||||||
case 8:
|
|
||||||
fmt.Println("You are 8%")
|
|
||||||
//switch传透下一层
|
|
||||||
fallthrough
|
|
||||||
case 7:
|
|
||||||
fmt.Println("You are 7%")
|
|
||||||
case 6:
|
|
||||||
fmt.Println("You are 6%")
|
|
||||||
case 5:
|
|
||||||
fmt.Println("You are 5%")
|
|
||||||
case 4:
|
|
||||||
fmt.Println("You are 4%")
|
|
||||||
case 3:
|
|
||||||
fmt.Println("You are 3%")
|
|
||||||
case 2:
|
|
||||||
fmt.Println("You are 2%")
|
|
||||||
case 1:
|
|
||||||
fmt.Println("You are 1%")
|
|
||||||
|
|
||||||
default:
|
|
||||||
fmt.Println("You are 0%")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user