• Javascript称球


    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        一道经典的智力题(12球称三次找出异常一球)

        有十二个乒乓球特征相同,其中只有一个重量异常,现在要求用一部没有砝码的天平称三次,将那个重量异常的球找出来。

      评分标准:
      1、30分钟以内做出来:智力很高很高很高,不知道有多高。
      2、60分钟以内做出来:智力很高。
      3、两小时内做出来: 智力相当高。
      4、1天或者1周内做出来:智力也很高,而且还是一个有毅力的人。
      5、10分钟内做出来:你或者以前做过,或者多半是个马虎的人。

    这里的问题关键是异常,所以不知道是轻了,还是重了,并且解题最后还要知道这球是轻还是重了。

        </div>
        <div>
         <select name=one></select>
    <select name=two></select>
    <select name=three></select>
    <select name=four></select>

    <script>
    var arrSel=["one","two","three","four"];//arrSel定义了要修改的下拉框
    var i=0,arrData=[];//arrData中搁的是数据,每条都显示各级的数据
    arrData[i++]=["(1,2,3,4)比(5,6,7,8)","请先做前面的选择","请先做前面的选择","请先做前面的选择"]
    arrData[i++]=["重","(1,2,5)比(3,6,9)","请先做前面的选择","请先做前面的选择"]
    arrData[i++]=["重","重","(1)比(2)","请先做前面的选择"]
    arrData[i++]=["重","重","重","1球比较重"]
    arrData[i++]=["重","重","平","6球比较轻"]
    arrData[i++]=["重","重","轻","2球比较重"]
    arrData[i++]=["重","平","(7)比(8)","请先做前面的选择"]
    arrData[i++]=["重","平","重","8球比较轻"]
    arrData[i++]=["重","平","平","4球比较重"]
    arrData[i++]=["重","平","轻","7球比较轻"]
    arrData[i++]=["重","轻","(1)比(3)","请先做前面的选择"]
    arrData[i++]=["重","轻","重","无解"]
    arrData[i++]=["重","轻","平","5球比较轻"]
    arrData[i++]=["重","轻","轻","3球比较重"]
    arrData[i++]=["平","(9,10)比(1,11)","请先做前面的选择","请先做前面的选择"]
    arrData[i++]=["平","重","(9)比(11)","请先做前面的选择"]
    arrData[i++]=["平","重","重","9球比较重"]
    arrData[i++]=["平","重","平","11球比较轻"]
    arrData[i++]=["平","重","轻","10球比较重"]
    arrData[i++]=["平","平","(1)比(12)","请先做前面的选择"]
    arrData[i++]=["平","平","重","12球比较轻"]
    arrData[i++]=["平","平","平","无解"]
    arrData[i++]=["平","平","轻","12球比较重"]
    arrData[i++]=["平","轻","(9)比(10)","请先做前面的选择"]
    arrData[i++]=["平","轻","重","9球比较轻"]
    arrData[i++]=["平","轻","平","11球比较重"]
    arrData[i++]=["平","轻","轻","10球比较轻"]
    arrData[i++]=["轻","(1,2,5)比(3,6,9)","请先做前面的选择","请先做前面的选择"]
    arrData[i++]=["轻","重","(1)比(3)","请先做前面的选择"]
    arrData[i++]=["轻","重","重","3球比较轻"]
    arrData[i++]=["轻","重","平","5球比较重"]
    arrData[i++]=["轻","重","轻","无解"]
    arrData[i++]=["轻","平","(7)比(8)","请先做前面的选择"]
    arrData[i++]=["轻","平","重","7球比较重"]
    arrData[i++]=["轻","平","平","4球比较轻"]
    arrData[i++]=["轻","平","轻","8球比较重"]
    arrData[i++]=["轻","轻","(1)比(2)","请先做前面的选择"]
    arrData[i++]=["轻","轻","重","2球比较轻"]
    arrData[i++]=["轻","轻","平","6球比较重"]
    arrData[i++]=["轻","轻","轻","1球比较轻"]
    </script>
    <script>
    function qswhInit(num){
    /******* by qiushuiwuhen(2002-5-15) ********/
     var i,j,arrTemp=[];
     for(i=0;i<num;i++)arrTemp[i]=document.all(arrSel[i]).options[document.all(arrSel[i]).selectedIndex].text
     if(num==arrSel.length){//这里处理最后的数据。
      return;
     }
     with(document.all(arrSel[num])){
      length=0
      for(i=0;i<arrData.length;i++){  
       for(j=0;j<num;j++)if(arrTemp[j]!=arrData[i][j])break;
       if(j!=num)continue;
       if(length==0||options[length-1].text!=arrData[i][num])
       options[length++].text=arrData[i][num];
      }
      onchange=new Function("qswhInit("+(num+1)+")");
      onchange();
     }
    }
    qswhInit(0);//初始化
    </script>
        </div>
        </form>
    </body>
    </html>

  • 相关阅读:
    我这些年的项目管理心得...
    14条建议,使你的IT职业生涯更上一层楼
    手机通过WIFI连上ZXV10 H618B路由器但不能上网问题的解决
    优秀中层必备的十大能力
    IMX51启动模式
    VS2005工程由Pocket PC 2003 SDK转为WINCE6.0 SDK的问题
    VS2005工程增加SDK
    VS2005下开发PPC2003和WM50编译器一些设置
    CTO俱乐部下午茶:技术团队管理中的那些事儿
    Android通过JNI调用驱动程序(完全解析实例)
  • 原文地址:https://www.cnblogs.com/lhking/p/1372500.html
Copyright © 2020-2023  润新知