如何从n个数当中取n个不重复的数

      Flash 2006-3-27 14:4
pointArray = new Array();
tempArray = new Array();
num = 30;
for (var i = 0; i<num; i++) {
pointArray.push(i);
}
function getRan(ran) { 
return pointArray[ran];
}
function saveData() {
for (var i = 0; i<10; i++) { 
len = pointArray.length-1;
n = int(Math.random()*len);
tempArray.push(getRan(n));
pointArray.splice(n,1)
}
}
saveData();
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}