-
Notifications
You must be signed in to change notification settings - Fork 0
随机彩票
heboliufengjie edited this page Feb 3, 2016
·
3 revisions
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>彩票</title>
<script>
/*
1 一共6位 存数组
2 范围 [1,33] 随机函数
3 不重复 排除
*/
var arr = [];
function rnd(n,m){
return parseInt(Math.random()*(m-n) + n);
}
function findInArr(arr,n){
for(var i = 0; i < arr.length; i++){
if(arr[i] == n){
return true;
}
}
return false;
}
while(arr.length < 6){
var n = rnd(1,34);
if(findInArr(arr,n) == false){
arr.push(n);
}
}
document.write(arr);
</script>
</head>
<body>
</body>
</html>