解题笔记(3)――随机数选择 - wuzhekai的专栏 - 博客频道 - CSDN.NET
问题: 从0, 1 ,2 ... n-1中随机选择m个数,每个数选中的概率要求一样,而且不允许重复。选中的数按顺序输出。比如,0, 1, 2, 3, 4, 5中随机选3个数,如果选的是1,4, 5,那么输出的顺序也应该是1, 4, 5。下面实现中,用的随机函数都是C的库函数,这个函数产生的随机数的范围是限定的,[0, 32767],如果要产生更大的随机数,需另外实现随机函数,将rand() 替换掉。比如下面这个函数。
Read full article from 解题笔记(3)――随机数选择 - wuzhekai的专栏 - 博客频道 - CSDN.NET
No comments:
Post a Comment