<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>双色球生成器</title>
</head>
<body>
<div style="margin: 0 auto;padding: 0px;background-color: cadetblue;text-align: center;width:auto;height: auto">
    <h1>双色球生成器</h1>
    <form>
        <input type="button" value="机选按钮" onclick="random()"/>
    </form>
</div>
<script>
function random() {
    var array = new Array(7);
    for(var i=0;i<array.length;i++){
        array[i] = Math.ceil(Math.random()*33);//向上转型
        if(i===6){
            array[i] = Math.ceil(Math.random()*16)
        }
    }
for(var i=0;i<array.length-1;i++){
        for(var j=0;j<array.length-2;j++){
           if(array[j]>array[j+1]){
               a = array[j];
               array[j] = array[j+1];
               array[j+1] = a;
           }
        }
}
    alert("第1个红球:"+array[0]+"\n"+"第2个红球:"+array[1]+"\n"+"第3个红球:"+array[2]+"\n"+
        "第4个红球:"+array[3]+"\n"+"第5个红球:"+array[4]+"\n"+"第6个红球:"+array[5]+"\n"+"蓝球:| "+array[6]);
}

</script>
</body>
</html>
05-08 08:16