CSDN博客

img qiushuiwuhen

称三次从12球中找出唯一但不知轻重的球

发表于2003/7/22 7:57:00  1098人阅读

在12个小球中有一个和其他不同(或轻或重),现在先拿起笔,记下哪个球重或者轻,然后继续下面的游戏<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中搁的是数据,每条都显示各级的数据
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)比(10)","请先做前面的选择"]
arrData[i++]=["平","重","重","9球比较重"]
arrData[i++]=["平","重","平","10球比较重"]
arrData[i++]=["平","重","轻","11球比较轻"]
arrData[i++]=["平","平","(1)比(12)","请先做前面的选择"]
arrData[i++]=["平","平","重","12球比较轻"]
arrData[i++]=["平","平","平","无解"]
arrData[i++]=["平","平","轻","12球比较重"]
arrData[i++]=["平","轻","(9)比(10)","请先做前面的选择"]
arrData[i++]=["平","轻","重","9球比较轻"]
arrData[i++]=["平","轻","平","10球比较轻"]
arrData[i++]=["平","轻","轻","11球比较重"]
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>

0 0

相关博文

我的热门文章

img
取 消
img