加了种子之后,为什么变成相同的金额
没加种子
加了种子
没加种子
加了种子
2019-04-15
您好!@慕粉4294199 可以参考infra/algo/algo_test.go:8
TestSimpleRand
中的代码,例子中的方法并非生成一个实际的序列,只是随机演示的,代码如下:
func main() {
count, amount := int64(10), int64(100)
remain := amount * 100
for i := int64(0); i < count; i++ {
x := algo.SimpleRand(count-i, remain)
remain -= x
fmt.Print(float64(x)/float64(100), ",")
}
fmt.Println()
}另外,课程中的例子我在mac os下运行时良好的,没有相同金额的问题。
举报