day29

1.     JavaScript抽奖游戏

[html]  view plain  copy
  1.   <script type="text/javascript">  
  2.   
  3.        var alldata ="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"  
  4.   
  5.        var alldataarr = alldata.split(",");  
  6.   
  7.        var num = alldataarr.length - 1;  
  8.   
  9.        var timer;      
  10.   
  11.        function start() {  
  12.   
  13.            clearInterval(timer);h  
  14.   
  15.            timer = setInterval('change()', 10);  
  16.   
  17.        }  
  18.   
  19.        function change() {  
  20.   
  21.            document.getElementById("oknum").innerHTML =alldataarr[GetRnd(0, num)];  
  22.   
  23.        }  
  24.   
  25.        function GetRnd(min, max) {  
  26.   
  27.            return parseInt(Math.random() * (max - min + 1));  
  28.   
  29.        }      
  30.   
  31.        function ok() {  
  32.   
  33.            clearInterval(timer);  
  34.   
  35.            document.getElementById("showresult").value =document.getElementById("oknum").innerText;  
  36.   
  37.        }       
  38.   
  39. </script>  
  40.   
  41. </head>  
  42.   
  43. <body>  
  44.   
  45.    
  46.   
  47. <div id="oknum"name="oknum" >请单击开始</div>  
  48.   
  49.    <button onclick="start()" accesskey="s">开始</button>    <!--//accesskey 属性规定激活(使元素获得焦点)元素的快捷键。-->  
  50.   
  51. <button onclick="ok()"accesskey="o">停止</button>  
  52.   
  53. 您的选择是:  
  54.   
  55. <input type="text"id="showresult" value=""/>  
  56.   
  57. </body>  
  58.   
  59. </html>   

2. 现在有一张正在使用的表,数据量为1000W,如何做优化?

1、在查询概率高的字段上建立索引;

2、将表分区,如按月份分12个区;

3、优化SQL语句;

4、控制查询条件;

5、定期备份数据库,将过去一段时间内的数据清除。

3. java题:验证歌德巴赫猜想,输入一个大于6的偶数,请输出这个偶数能被分解为哪两个质数的和

如 10=3+7    12=5+7  

质数:除了1和自身,不能被任何数整除的数

[java]  view plain  copy
  1. public class Demo {   
  2.   
  3.    
  4.   
  5.    public static void main(String[] args) {   
  6.   
  7.        Scanner in = new Scanner(System.in);   
  8.   
  9.        int x;   
  10.   
  11.        do {   
  12.   
  13.            System.out.print("请输入一个大于6的偶数:");   
  14.   
  15.            x = in.nextInt();   
  16.   
  17.        } while (!((x > 6) && (x % 2 == 0)));   
  18.   
  19.        for(int i=2;i<x/2;i++){   
  20.   
  21.            if((prime(x))&&(prime(x-i))){   
  22.   
  23.                System.out.println(i+","+(x-i));   
  24.   
  25.            }   
  26.   
  27.            System.out.println(i+","+(x-i));   
  28.   
  29.        }   
  30.   
  31.    
  32.   
  33.  }   
  34.   
  35.    public static boolean prime(int n){   
  36.   
  37.        for(int i=2;i<=(int)(Math.sqrt((double)n));i++){   
  38.   
  39.            if(n%i==0){   
  40.   
  41.                 return false;   
  42.   
  43.            }   
  44.   
  45.        }   
  46.   
  47.            return true;   
  48.   
  49.        }   
  50.   
  51.    }   
  52.   
  53.    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值