<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>双色球摇号</title> </head> <body> <script> const qiu = []; function pro() { let qs = []; // 生产6个红球 while (qs.length < 6) { const q = Math.ceil(Math.random() * 33); if (!qs.includes(q)) { qs.push(q); } } qs.sort((a, b) => a - b); // 生成1个蓝球 const q = Math.ceil(Math.random() * 16); qs.push(q); return qs; } // 生成五注 for (var i = 0; i < 5; i++) { const one = pro(); console.log(`%c${one.slice(0,6).join(',')}-%c${one[6]}`, 'color: red', 'color: blue'); } // console.log(pro()); </script> </body> </html>
标签:摇号,双色球,const,pro,qs,Math,模拟 From: https://www.cnblogs.com/hello-dummy/p/17247506.html