随笔-42  评论-42  文章-0  trackbacks-0

1 题目如下:( http://www.javaeye.com/topic/226364?page=1
给你10分钟时间,根据上排给出十个数,在其下排填出对应的十个数
要求下排每个数都是先前上排那十个数在下排出现的次数。
上排的十个数如下:
【0,1,2,3,4,5,6,7,8,9】

小提示:下排的10个数之和正好是10

答案:
##########【1】##########
##########【2】##########
##########【3】##########
##########【4】##########
数值:0,1,2,3
分配:1,2,1,0
数值:0,1,2,3
分配:2,0,2,0
##########【5】##########
数值:0,1,2,3,4
分配:2,1,2,0,0
##########【6】##########
##########【7】##########
数值:0,1,2,3,4,5,6
分配:3,2,1,1,0,0,0
##########【8】##########
数值:0,1,2,3,4,5,6,7
分配:4,2,1,0,1,0,0,0
##########【9】##########
数值:0,1,2,3,4,5,6,7,8
分配:5,2,1,0,0,1,0,0,0
##########【10】##########
数值:0,1,2,3,4,5,6,7,8,9
分配:6,2,1,0,0,0,1,0,0,0
##########【11】##########
数值:0,1,2,3,4,5,6,7,8,9,10
分配:7,2,1,0,0,0,0,1,0,0,0
##########【12】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11
分配:8,2,1,0,0,0,0,0,1,0,0,0
##########【13】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11,12
分配:9,2,1,0,0,0,0,0,0,1,0,0,0
##########【14】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11,12,13
分配:10,2,1,0,0,0,0,0,0,0,1,0,0,0
##########【15】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
分配:11,2,1,0,0,0,0,0,0,0,0,1,0,0,0
##########【16】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
分配:12,2,1,0,0,0,0,0,0,0,0,0,1,0,0,0
##########【17】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
分配:13,2,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0
##########【18】##########
数值:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
分配:14,2,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0

只是不知道是否唯一?

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

 
答案: 一个很酷的JS写的解法 http://www.blueidea.com/bbs/NewsDetail.asp?id=523379
 1 在12个小球中有一个和其他不同(或轻或重),现在先拿起笔,记下哪个球重或者轻,然后继续下面的游戏<br><br><br>
 2 <select name=one></select>
 3 <select name=two></select>
 4 <select name=three></select>
 5 <select name=four></select>
 6 
 7 <script>
 8 var arrSel=["one","two","three","four"];//arrSel定义了要修改的下拉框
 9 var i=0,arrData=[];//arrData中搁的是数据,每条都显示各级的数据
10 arrData[i++]=["(1,2,3,4)比(5,6,7,8)","请先做前面的选择","请先做前面的选择","请先做前面的选择"]
11 arrData[i++]=["","(1,2,5)比(3,6,9)","请先做前面的选择","请先做前面的选择"]
12 arrData[i++]=["","","(1)比(2)","请先做前面的选择"]
13 arrData[i++]=["","","","1球比较重"]
14 arrData[i++]=["","","","6球比较轻"]
15 arrData[i++]=["","","","2球比较重"]
16 arrData[i++]=["","","(7)比(8)","请先做前面的选择"]
17 arrData[i++]=["","","","8球比较轻"]
18 arrData[i++]=["","","","4球比较重"]
19 arrData[i++]=["","","","7球比较轻"]
20 arrData[i++]=["","","(1)比(3)","请先做前面的选择"]
21 arrData[i++]=["","","","无解"]
22 arrData[i++]=["","","","5球比较轻"]
23 arrData[i++]=["","","","3球比较重"]
24 arrData[i++]=["","(9,10)比(1,11)","请先做前面的选择","请先做前面的选择"]
25 arrData[i++]=["","","(9)比(11)","请先做前面的选择"]
26 arrData[i++]=["","","","9球比较重"]
27 arrData[i++]=["","","","11球比较轻"]
28 arrData[i++]=["","","","10球比较重"]
29 arrData[i++]=["","","(1)比(12)","请先做前面的选择"]
30 arrData[i++]=["","","","12球比较轻"]
31 arrData[i++]=["","","","无解"]
32 arrData[i++]=["","","","12球比较重"]
33 arrData[i++]=["","","(9)比(10)","请先做前面的选择"]
34 arrData[i++]=["","","","9球比较轻"]
35 arrData[i++]=["","","","11球比较重"]
36 arrData[i++]=["","","","10球比较轻"]
37 arrData[i++]=["","(1,2,5)比(3,6,9)","请先做前面的选择","请先做前面的选择"]
38 arrData[i++]=["","","(1)比(3)","请先做前面的选择"]
39 arrData[i++]=["","","","3球比较轻"]
40 arrData[i++]=["","","","5球比较重"]
41 arrData[i++]=["","","","无解"]
42 arrData[i++]=["","","(7)比(8)","请先做前面的选择"]
43 arrData[i++]=["","","","7球比较重"]
44 arrData[i++]=["","","","4球比较轻"]
45 arrData[i++]=["","","","8球比较重"]
46 arrData[i++]=["","","(1)比(2)","请先做前面的选择"]
47 arrData[i++]=["","","","2球比较轻"]
48 arrData[i++]=["","","","6球比较重"]
49 arrData[i++]=["","","","1球比较轻"]
50 </script>
51 <script>
52 function qswhInit(num){
53 /******* by qiushuiwuhen(2002-5-15) ********/
54     var i,j,arrTemp=[];
55     for(i=0;i<num;i++)arrTemp[i]=document.all(arrSel[i]).options[document.all(arrSel[i]).selectedIndex].text
56     if(num==arrSel.length){//这里处理最后的数据。
57         return;
58     }
59     with(document.all(arrSel[num])){
60         length=0
61         for(i=0;i<arrData.length;i++){        
62             for(j=0;j<num;j++)if(arrTemp[j]!=arrData[i][j])break;
63             if(j!=num)continue;
64             if(length==0||options[length-1].text!=arrData[i][num])
65             options[length++].text=arrData[i][num];
66         }
67         onchange=new Function("qswhInit("+(num+1)+")");
68         onchange();
69     }
70 }
71 qswhInit(0);//初始化
72 </script>
73 
posted on 2008-08-15 09:27 BlueSunshine 阅读(252) 评论(0)  编辑  收藏 所属分类: 个人日记

只有注册用户登录后才能发表评论。


网站导航: