<xmp id="youqw">
<xmp id="youqw">
  • <blockquote id="youqw"><blockquote id="youqw"></blockquote></blockquote>
    站長工具,就用查一把!
    收錄查詢  關鍵詞排名  Alexa排名  PR檢測  友情檢測  IP反查  WHOIS查詢   更多查詢 
      收藏  最近查詢 查一把
    信息分類 首頁 » 資訊信息

    好站推薦

    IT新聞

      業界猜想

      名人名企

    建站推廣

      站長創業

      運營推廣

    設計編程

      美工設計

      開發編程

    解24點的網頁源碼,這個真不錯 能計算所有的數字的24值
    信息來源:圖王-A5論壇 發布時間:2011/9/15

    <html>
    <head>
    <title>24點(電腦幫你算) 算24的頁面 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

    </head>

    <body bgcolor="#FEEFFD">

    <div align="center" style="width: 750; height: 431">
    <center>
    <table border=0 cellpadding=3 cellspacing=0 class=TableBorder1 width="760" style="border-collapse: collapse" bordercolor="#111111" height="519">
    <tr>
    <th height="35" align="center" valign="middle" width="112">
     </th>
    <th height="35" align="center" valign="middle" width="632">
    <p align="left">
    <font style="font-size: 15pt" face="黑體" color="#008000">24點(電腦幫你算)</font><font style="font-size: 15pt" face="楷體_GB2312" color="#008000"><br>
    </font>
    <tr>
    <td height="8" valign="top" class=TableBody1 width="1">
    </td>
    <td height="8" valign="top" class=TableBody1 width="1113">
    <hr color="#B014E4" width="95%" align="left"></td>
    </tr>
    <tr>
    <td height="436" valign="top" class=TableBody1 width="1">
    </td>
    <td height="436" valign="top" class=TableBody1 width="1113">
    <br>
     <br>
    計算24點(加、減、乘、除、括號)<br><br>
    <br><br>
    玩法:從撲克中任意抽出四張(數字表示為1-13),用加、減、乘、除的方法使結果成為24,每張牌只能用一次。
    一副牌(52張)中,任意抽取4張可有1820種不同組合,其中有458個牌組算不出24點,F在再和別人玩這個游戲,不怕了吧?Let's play cards!<br><br><br>
    <form>
    請輸入四個數字(1-13):<br><br>
    <input type="text" name="fa" size="2">
    <input type="text" name="fb" size="2">
    <input type="text" name="fc" size="2">
    <input type="text" name="fd" size="2">
    <br><br><input type="button" name="btn" onclick="javascript:funCount()" value=" 計算 ">
    </form>
    <br><script language="JavaScript">
    function log(str)
    {
    document.write("<br>"+str);
    }
    //生成計算表達式
    function genExpress(exp,a,b,c,d,m1,m2,m3)
    {
    var exp=exp.replace("a",a);
    exp=exp.replace("b",b);
    exp=exp.replace("c",c);
    exp=exp.replace("d",d);
    exp=exp.replace("m1",m1);
    exp=exp.replace("m2",m2);
    exp=exp.replace("m3",m3);
    return exp;
    }
    var answer = new Array();//正確答案的表達式
    var counter = 0;//答案的個數
    //測試表達式是否正確
    function test(expn,a,b,c,d,m1,m2,m3)
    {
    var exp;
    var ret;
    exp = genExpress(expn,a,b,c,d,m1,m2,m3);//生成計算表達式
    eval("ret = "+exp);
    if ( Math.abs(ret - 24) < 0.1 )
    {
    exp = exp.replace(";","");
    exp = replaceAll(exp,"*","×");
    exp = replaceAll(exp, "/","÷");
    var have = false;
    for ( var i=0; i<counter; i++)
    {
    if ( exp == answer[i] )
    {
    have = true;
    break;
    }
    }
    if ( !have )
    {
    answer[counter] = exp;
    counter++;
    log("<font color=red><b>"+counter+":  "+exp+"</b></font>");
    }
    }
    }
    function replaceAll (streng, soeg, erstat)
    {
    var st = streng;
    if (soeg.length == 0)
    return st;
    var idx = st.indexOf(soeg);
    while (idx >= 0)
    {
    st = st.substring(0,idx) + erstat + st.substr(idx+soeg.length);
    idx = st.indexOf(soeg);
    }
    return st;
    }
    var n = new Array();//四個數字
    //接收四個輸入框的數字,調用主程序
    function funCount()
    {
    n[0] = document.forms[0].fa.value;
    n[1] = document.forms[0].fb.value;
    n[2] = document.forms[0].fc.value;
    n[3] = document.forms[0].fd.value;
    if ( n[0] > 0 && n[1] > 0 && n[2] > 0 && n[3] > 0 && n[0] < 14 && n[1] < 14 && n[2] < 14 && n[3] < 14 )
    {
    log("<font size=5><b>"+n[0]+", "+n[1]+", "+n[2]+", "+n[3]+"的24點答案:</b></font><br>");
    log("<input type='button' onclick='history.back(-1);' value=' 再來一次 '><br>");
    funMain();
    if ( counter == 0 )
    {
    log("沒有答案!");
    }
    }
    else
    {
    alert("輸入錯誤!");
    }
    }
    //主程序
    function funMain()
    {
    var m = new Array();
    //四種運算符
    m[0] = "+";
    m[1] = "-";
    m[2] = "*";
    m[3] = "/";

    //11種表達式
    var exp1 = "a m1 b m2 c m3 d;";
    var exp2 = "(a m1 b) m2 c m3 d;";
    var exp3 = "(a m1 b m2 c) m3 d;";
    var exp4 = "((a m1 b) m2 c) m3 d;";
    var exp5 = "(a m1 (b m2 c)) m3 d;";
    var exp6 = "a m1 (b m2 c) m3 d;";
    var exp7 = "a m1 (b m2 c m3 d);";
    var exp8 = "a m1 ((b m2 c) m3 d);";
    var exp9 = "a m1 (b m2 (c m3 d));";
    var exp10 = "a m1 b m2(c m3 d);";
    var exp11 = "(a m1 b) m2 (c m3 d);";

    var a,b,c,d;//四個數字
    var m1,m2,m3;//三個運算符

    for (var i=0;i<4;i++)
    {
    a = n[i];
    for (var j=0;j<4;j++)
    {
    if ( i == j ) continue;//從未選的三個數字中選擇一個數字
    b = n[j];
    for (var x=0;x<4;x++)
    {
    if ( x == j || x == i ) continue;//從未選的兩個數字中選擇一個數字
    c = n[x];
    for (var y=0;y<4;y++)
    {
    if ( y == x || y == j || y == i ) continue;//從未選的一個數字中選擇一個數字
    d = n[y];

    for (var ta=0;ta<4;ta++)
    {
    m1 = m[ta];
    for (var tb=0;tb<4;tb++)
    {
    m2 = m[tb];
    for (var tc=0;tc<4;tc++)
    {
    m3 = m[tc];
    for (var k=1;k<12;k++)
    {
    eval("test(exp"+k+",a,b,c,d,m1,m2,m3);");
    }
    }
    }
    }
    }
    }
    }
    }
    }
    </script>

    網友點評
    国产AV精选aaaaaaa