锻炼速算能力的单个网页(可在手机上用)

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>四则运算练习</title>
    </head>
    <body>
        <fieldset>
            <legend>配置</legend>
            <span>位数</span>
            <select id="weishu">
                <option value=1>个</option>
                <option value=2>十</option>
                <option value=3>百</option>
                <option value=4>千</option>
            </select>
            <span>算法</span>
            <select id="operate">
                <option value=1>加</option>
                <option value=2>减</option>
                <option value=3>乘</option>
                <option value=4>除</option>
                <option value=5>随机</option>
            </select>
        </fieldset>
        <fieldset>
            <legend>操作</legend>
            <span id="exp_expr"></span>
            =
            <input id ="exp_answer" type="number" value="" />
            <p id="exp_correct"></p>
        </fieldset>
    </body>
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script>
        $(function(){
            var weishu = $('#weishu');
            var operate = $('#operate');
            var exp_expr = $('#exp_expr');
            var exp_answer = $('#exp_answer');
            var exp_correct = $('#exp_correct');

            function random(){
                var ws = parseInt(weishu.val());
                var min = Math.pow(10, ws - 1);
                var max = Math.pow(10, ws) - 1;
                return Math.floor(Math.random() * (max - min) +  min)
            }
            
            var exp_new = function(){
                exp_answer.val('');
                exp_correct.text(' ');
                exp_answer.focus();
                
                var opr = parseInt(operate.val());
                var result = NaN;

                if (opr == 5) {
                            opr = Math.floor(Math.random() * 3 +  1)
                }

                switch(opr){
                case 1:
                    var left = random();
                    var right = random();
                    result = left + right;
                    exp_expr.text(left.toString() + ' + ' + right.toString());
                    break;
                case 2:
                    var left = random();
                    var right = random();
                    if (left < right) {
                        var temp = left;
                        left = right;
                        right = temp;
                    }
                    result = left - right;
                    exp_expr.text(left.toString() + ' - ' + right.toString());
                    break;
                case 3:
                    var left = random();
                    var right = random();
                    result = left * right;
                    exp_expr.text(left.toString() + ' * ' + right.toString());
                    break;
                case 4:
                    var right = 0;
                    for(;right == 0; right = random());
                    var left = right * random()
                    result = left / right;
                    exp_expr.text(left.toString() + ' / ' + right.toString());
                    break;
                }

                var start = (new Date()).valueOf();
                exp_answer.keyup(function(){
                    var answer = parseInt(exp_answer.val());
                    if (answer != result) {
                        exp_correct.text('错误');
                    } else {
                        var end = (new Date()).valueOf();
                        exp_correct.text('正确,用时' + ((end - start)/1000).toString() + '秒');
                        setTimeout(exp_new, 1000);
                        exp_answer.unbind('keyup');
                    }
                });
            }
            weishu.change(exp_new);
            operate.change(exp_new);

            exp_new();
        });
    </script>
</html>