![go无运行结果.png](https://static.studygolang.com/220213/f08f57c0c4b09a2d09da8360c4c93f23.png)
更多评论
下面是代码的原文哈
package main
import(
"fmt"
"math/rand"
)
func main(){
const num0 = 55
var num = rand.Intn(100) + 1
for num == num0{
switch{
case num == num0:
fmt.Println("U r right! The value is ",num0,"!")
case num > num0:
fmt.Println("The value should be greater!")
num = rand.Intn(100) + 1
case num < num0:
fmt.Println("The value should be less!")
num = rand.Intn(100) + 1
}
}
}
#1
package main
import(
"fmt"
"math/rand"
)
func main(){
const num0 = 55
var num = rand.Intn(100) + 1
re:
for {
switch {
case num == num0:
fmt.Println("U r right! The value is ",num0,"!")
break re
case num > num0:
fmt.Println("The value should be greater!")
num = rand.Intn(100) + 1
case num < num0:
fmt.Println("The value should be less!")
num = rand.Intn(100) + 1
}
}
}
#3