码迷,mamicode.com
首页 > 其他好文 > 详细

双色球的随机

时间:2018-08-10 19:43:59      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:floor   var   function   mat   ons   dom   math   random   双色球   

//随机数  双色球

var compare = function (x, y) {//比较函数
if (x < y) {
return -1;
} else if (x > y) {
return 1;
} else {
return 0;
}
}

num1 = Math.floor(Math.random() * 32)+1;
num2 = Math.floor(Math.random() * 32)+1;
num3 = Math.floor(Math.random() * 32)+1;
num4 = Math.floor(Math.random() * 32)+1;
num5 = Math.floor(Math.random() * 32)+1;
num6 = Math.floor(Math.random() * 32)+1;
num7 = Math.floor(Math.random() * 16)+1;

var arr = [num1, num2, num3, num4, num5, num6];

arr.sort(compare);
console.log(arr,num7);

双色球的随机

标签:floor   var   function   mat   ons   dom   math   random   双色球   

原文地址:https://www.cnblogs.com/shenbo666/p/9456620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!