zoukankan      html  css  js  c++  java
  • 舒尔特方格

    舒尔特方格
    <script>
    window.onload=function(){
        var list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
        var new_list = [];
        while(true){
             if(list.length == 0){
                break;
             }
             var num = parseInt(Math.random()*25+1,10);
             var index = list.indexOf(num);
             if(index == -1){
                continue;
             }
             list.splice(index,1);
             new_list.push(num);
        }
        var table = document.getElementById("table");
        var index = 0;
        for(var i=0;i<5;i++){
            var tr = document.createElement("tr");
            for(var j=0;j<5;j++){
                var td = document.createElement("td");
                var num = document.createTextNode(new_list[index]);
                var button = document.createElement("button");
                var font = document.createElement("font");
                font.setAttribute("size",10);
               
                font.appendChild(num);
                button.appendChild(font);
                button.setAttribute("value",new_list[index]);
                button.setAttribute("style","height:100px;100px");
                td.appendChild(button);
                td.setAttribute("align","center");
                button.setAttribute("onclick","clickEvent(this)");
                tr.appendChild(td);
                 index ++;
            }
            table.appendChild(tr);
        }     
    }
    var arrary = [];
    var time_array = [];
      function clickEvent(obj){
            var num = parseInt(obj.getAttribute("value"));
            if(arrary.length == 0 && num != 1){
                alert("失败!");
                return
            }
            if(num == 1){
                 arrary.push(num);
                var myDate = new Date();
                 var begin = myDate.getSeconds();
                 time_array.push(begin);
            }else{
                if(num==25 && arrary.length==24){
                     var myDate = new Date();
                     var end = myDate.getSeconds();
                     if(parseInt(end) >  time_array[0]){
                         var time = end - time_array[0];
                        alert("success! time:" + time);
                        return
                     }else{
                         var time = end - time_array[0]+60;
                        alert("success! time:" + time);
                        return
                     }
                   
                }
                var lastElement = arrary[arrary.length-1];
                if(num-1 != lastElement){
                    alert("失败!");
                    return
                }
                arrary.push(num);
            }  
        }   
    
    </script>
    
  • 相关阅读:
    解决了Excel的一个貌似很奇怪的问题~~~
    关闭子页面,刷新父页面
    动态控制DataGrid中的TextBox的状态及输入值!!
    C#对Oracle BLOB字段的写入读取方法
    谈恋爱,好累...
    可移植,可扩展高效Proactor模式
    When are asynchronous file writes not asynchronous...
    [转]How to support 10,000 or more concurrent TCP connections
    [转]Creating a forwarding dll
    [转]非金钱激励员工的108种手段
  • 原文地址:https://www.cnblogs.com/RomanticLife/p/9968666.html
Copyright © 2011-2022 走看看