日期:2014-05-16 浏览次数:20375 次
for(i=0; i<30; i++) {
document.write(Math.floor(Math.random()*52) + '<br>');
}
function getDifNum(num,minNum,maxNum){
var res = [],
i=0,
len,
flag=false,
btn;
if(typeof maxNum != "number"){
maxNum = minNum;
minNum = 0;
}
if(maxNum <= minNum){
return;
}
btn = maxNum - minNum;
if(num >= btn){
return;
}else if(num > Math.ceil(btn/2)){
num = btn - num;
flag = true;
}
res = getRandArr(num,minNum,maxNum);
function getArr(num){
var arr = [],
i=0;
for(;i<num;i++){
arr[i] = i;
}
return arr;
}
function getRandArr(num,min,max){
var arr = [];
for(var i = 0;i<num;i++){
arr[i] = getRandNum(min,max);
}
return arr;
}
function getRandNum(min,max){
return Math.round(Math.random()*(max-min) + min)
}
function deleSame(arr){
var i=0;
arr.sort();
for(;i<arr.length;i++){
if(arr[i] == arr[i+1]){
arr.splice(i,1);
i--;
}
}
return arr;
}
function getOther(btn,arr){
var i=0,
len = arr.length;
var arr2 = getArr(btn),
btn = btn - arr.length;
for(i=0;i<