2016年6月3日 星期五


6/3 期末考 不重複


<html> <meta charset="UTF-8">  <head>   <title>期末2</title>  </head>  <body>   <script>    var balls = new Array(10);    var i=0,j=0,k=0;    for(i=0;i<10;i++)    {     balls[i]=i+1;    }    for(i=1;i<=1000;i++)    {     j=Math.floor(Math.random()*9);     k=Math.floor(Math.random()*9);     balls[49]=balls[j];     balls[j]=balls[k];     balls[k]=balls[49];    }    document.write(balls[0]+","+balls[1]+","+balls[2]);   </script>  </body> </html>

沒有留言:

張貼留言