基础
随机数。Math.random().参照 http://www.w3school.com.cn/js/jsref_random.asp.
范围从[0-1),能取到0不能取到1。参照msdn。mdc。ecma。
虽然有机会取到0.但是几乎取不到。因为有16个小数位。
取[0,1]
只取0或者1.
Math.floor(Math.random()*2)
取给定范围的随机
moo中有个取随机的函数。给定一个范围。可以取到[min,max]。更精确的范围是min.0-max.xxx。但是因为floor的缘故,xxx被省略了
function f(max,min)
return Math.floor(Math.random() * (max - min + 1) + min);
取给定范围的唯一的多个随机
从[min-max]中取n个随机数。这就是排列问题了
funtion f(max,min,n)
这个会在算法里面说到