作者PwiPwiWorm (Valley of shadow)
看板C_and_CPP
标题Re: [问题] 乱数的问题
时间Fri Apr 7 12:21:53 2006
这个问题版上以前就有讨论过...
最大的盲点在常会做出机率不平均的permutation
而且STL中就有现成的function可用
{
const int N = 8;
int A[] = {1, 2, 3, 4, 5, 6, 7, 8};
random_shuffle(A, A + N);
}
方法出处是
D. E. Knuth, The Art of Computer Programming. Volume 2:
Seminumerical Algorithms, second edition. Addison-Wesley, 1981
section 3.4.2
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.125.77