福彩、体彩选号(HTML单机程序)

完全自主操作的随机选号程序。

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>彩票号码生成器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 600px;
            margin: auto;
            background: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h1 {
            text-align: center;
            color: #333;
        }
        .controls {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 20px;
        }
        .controls-row {
            display: flex;
            justify-content: center;
            margin-bottom: 10px;
        }
        .controls button {
            padding: 10px 20px;
            background-color: #00a1d6;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .controls button.selected {
            background-color: #007ba7;
        }
        .controls button:hover {
            background-color: #008bb9;
        }
        .controls button.round {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            line-height: 60px;
            padding: 0;
        }
        .result {
            list-style-type: none;
            padding: 0;
        }
        .result li {
            padding: 10px;
            border-bottom: 1px solid #eee;
        }
        .result li:last-child {
            border-bottom: none;
        }
        .number {
            display: inline-block;
            width: 30px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            margin: 5px;
            border-radius: 50%;
            color: white;
        }
        .red-ball {
            background-color: red;
        }
        .blue-ball {
            background-color: blue;
        }
        .green-ball {
            background-color: green;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>彩票号码生成器</h1>
        <div class="controls">
            <div class="controls-row">
                <button id="dltButton" onclick="setLotteryType('dlt')" class="selected">大乐透</button>
                <div style="width: 100px;"></div> <!-- Spacing between buttons -->
                <button id="ssqButton" onclick="setLotteryType('ssq')">双色球</button>
            </div>
            <div class="controls-row">
                <button onclick="generateNumbers()" class="round">生成</button>
            </div>
            <div class="controls-row">
                <button onclick="clearResults()">清空结果</button>
            </div>
        </div>
        <ul class="result" id="results"></ul>
    </div>

    <script>
        let lotteryType = 'dlt';

        function setLotteryType(type) {
            lotteryType = type;
            document.getElementById('dltButton').classList.toggle('selected', type === 'dlt');
            document.getElementById('ssqButton').classList.toggle('selected', type === 'ssq');
        }

        function generateNumbers() {
            let numbers;
            if (lotteryType === 'dlt') {
                numbers = generateDLTNumbers();
            } else if (lotteryType === 'ssq') {
                numbers = generateSSQNumbers();
            }

            const resultsList = document.getElementById('results');
            const newResult = document.createElement('li');

            numbers.forEach(number => {
                const span = document.createElement('span');
                span.className = number.type + '-ball number';
                span.textContent = number.value;
                newResult.appendChild(span);
            });

            resultsList.insertBefore(newResult, resultsList.firstChild);
        }

        function clearResults() {
            const resultsList = document.getElementById('results');
            resultsList.innerHTML = '';
        }

        function generateDLTNumbers() {
            const redBalls = shuffleArray([...Array(35).keys()].map(i => ({ value: i + 1, type: 'red' }))).slice(0, 5);
            const blueBalls = shuffleArray([...Array(12).keys()].map(i => ({ value: i + 1, type: 'blue' }))).slice(0, 2);
            return [...redBalls.sort((a, b) => a.value - b.value), ...blueBalls.sort((a, b) => a.value - b.value)];
        }

        function generateSSQNumbers() {
            const redBalls = shuffleArray([...Array(33).keys()].map(i => ({ value: i + 1, type: 'red' }))).slice(0, 6);
            const blueBall = shuffleArray([...Array(16).keys()].map(i => ({ value: i + 1, type: 'blue' }))).slice(0, 1);
            return [...redBalls.sort((a, b) => a.value - b.value), ...blueBall];
        }

        function shuffleArray(array) {
            for (let i = array.length - 1; i > 0; i--) {
                const j = Math.floor(Math.random() * (i + 1));
                [array[i], array[j]] = [array[j], array[i]];
            }
            return array;
        }
    </script>
</body>
</html>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值