请问一下这代码为什么没有运行结果啊(for+switch)

haozi · · 1041 次点击
num == num0 没有匹配到直接跳过了呀。
#11
更多评论
下面是代码的原文哈 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
把 for 删了不就完了 💦
#2