日期:2014-05-16 浏览次数:20453 次
<html> <head> <script> </script> </head> <body> 条件A:<INPUT type="text" name="a" size="5"> 条件B:<INPUT type="text" name="b" size="5"> <br> <br> <button onclick="func()">开始并计算</button> <br> <br> 结果:<INPUT type="text" name="c"> </body> </html>
<html> <body> <FORM METHOD=POST ACTION="" name="form1"> <button onclick="return func();">开始并计算</button> <br> <br> 我猜:<INPUT type="text" name="c"> 条件A:<INPUT type="text" name="a" size="5"> 条件B:<INPUT type="text" name="b" size="5"> 你的数字是:<INPUT type="text" name="d"> </FORM> </body> </html> <SCRIPT LANGUAGE="JavaScript"> <!-- var total = 0; var isValid = new Array(5040); for(var i=0;i<isValid.length;i++) { isValid[i]='true'; } var nums = new Array(5040 * 4); var pos = 0; //5040 * 4数组中的位置 var a, b, c, d; for (var aa = 0; aa < 10; aa++) { for (var bb = 0; bb < 10; bb++) { if (aa != bb) { for (var cc = 0; cc < 10; cc++) { if (aa!= cc && bb!= cc) { for (var dd = 0; dd < 10; dd++) { if (aa != dd && bb != dd && cc != dd) { nums[pos++] = aa; nums[pos++] = bb; nums[pos++] = cc; nums[pos++] = dd; } } } } } } } //form1.c.value = getgetNextSeed(); function func() { total++ var acount =form1.a.value; var bcount = form1.b.value; if(total>1) setGuessReuslt(acount, bcount); var guestNum = getgetNextSeed(); if(guestNum==true || acount==4) { alert("看,我猜对了吧,服不服,哈哈哈!!!"); if(acount==4) form1.d.value=form1.c.value; return true; } else { form1.c.value=guestNum; alert("第"+total+"次,我猜:"+guestNum); } } function setGuessReuslt(x,y) { if (x == 4) { return; } for (var pos = 0; pos < 5040; pos++) { if (isValid[pos]) { var numspos = pos * 4; if (getMyX(pos) != x) { isValid[pos] = false; continue; } if (getMyY(pos) != y) { isValid[pos] = false; continue; } } } } function getMyX(pos) { var myx = 0;