package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
const winners = 101 //内定号码
const isDefault = true //是否内定 true 是 false 否
number := [...]int{11, 22, 33, 44, 55, 66, 77, 88, 99, 00, 101}
total := len(number)
//将时间戳设置成种子数
rand.Seed(time.Now().UnixNano())
//随便展示一下
for i := total * 3; i >= 0; i-- {
fmt.Println("抽奖中:", number[rand.Intn(total)])
}
if isDefault {
fmt.Println("中奖者是:", winners)
} else {
fmt.Println("中奖者是:", number[rand.Intn(total)])
}
}
评论(0)