作者:藍(lán)色 時(shí)間: 2005-04-06 文檔類型:原創(chuàng) 來自:藍(lán)色理想
第 1 頁 12個(gè)球稱三次找出異常一球解法 [1] 第 2 頁 javascript 解法
運(yùn)行代碼框在12個(gè)小球中有一個(gè)和其他不同(或輕或重),現(xiàn)在先拿起筆,記下哪個(gè)球重或者輕,然后繼續(xù)下面的游戲<br><br><br> <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中擱的是數(shù)據(jù),每條都顯示各級的數(shù)據(jù) 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){//這里處理最后的數(shù)據(jù)。 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> [Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運(yùn)行]
原文鏈接:http://www.95time.cn/bbs/NewsDetail.asp?id=523379
出處:藍(lán)色理想 責(zé)任編輯:藍(lán)色
上一頁 12個(gè)球稱三次找出異常一球解法 [1] 下一頁
◎進(jìn)入論壇網(wǎng)頁制作、網(wǎng)站綜合版塊參加討論
藍(lán)色理想版權(quán)申明:除部分特別聲明不要轉(zhuǎn)載,或者授權(quán)我站獨(dú)家播發(fā)的文章外,大家可以自由轉(zhuǎn)載我站點(diǎn)的原創(chuàng)文章,但原作者和來自我站的鏈接必須保留(非我站原創(chuàng)的,按照原來自一節(jié),自行鏈接)。文章版權(quán)歸我站和作者共有。
轉(zhuǎn)載要求:轉(zhuǎn)載之圖片、文件,鏈接請不要盜鏈到本站,且不準(zhǔn)打上各自站點(diǎn)的水印,亦不能抹去我站點(diǎn)水印。
特別注意:本站所提供的攝影照片,插畫,設(shè)計(jì)作品,如需使用,請與原作者聯(lián)系,版權(quán)歸原作者所有,文章若有侵犯作者版權(quán),請與我們聯(lián)系,我們將立即刪除修改。