2016年6月2日 星期四

期中考

<html>
<script>
var answer;

function radom()
{

  answer="";
  var n1 = Math.floor(Math.random()*10);
  var n2 = Math.floor(Math.random()*10);
  var n3 = Math.floor(Math.random()*10);


  while(n2==n1)
  n2 = Math.floor(Math.random()*10);
  while((n3==n1)||(n3==n2))
  n3 = Math.floor(Math.random()*10);

  answer = n1+""+n2+""+n3;
  document.write(answer);

}
   </script>
<body>
 <input type="button" value="亂數" onclick="radom()"/>
</body>

</html>

沒有留言:

張貼留言