作者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