WEB版双色球号码随机生成代码(chatgpt)

<!doctype html>
<html>
    <head>
        <title>双色球号码随机生成</title>
        <script type="text/javascript">
            function generateBall(){
                var redBall = [];
                var blueBall;
                for(var i=0; i<6; i++){
                    var number = Math.floor(Math.random() * 33 + 1);
                    if(redBall.indexOf(number) !== -1){
                        i--;
                    }
                    else{
                        redBall.push(number);
                    }
                }
                blueBall = Math.floor(Math.random() * 16 + 1);
                redBall.sort(function(a,b){
                    return a-b;
                });
                document.getElementById('result').innerHTML = '红球:' + redBall + '  蓝球:' + blueBall;
            }
        </script>
    </head>

    <body>
    	<div>
    		<h1>双色球号码随机生成</h1>
    		<input type="button" value="生成号码" onclick="generateBall();">
    		<p id="result"></p>
    	</div>
    </body>
</html>
posted @ 2023-02-18 19:24  狗狗王  阅读(610)  评论(0编辑  收藏  举报