一个用来产生随机数的小例子

来源:互联网 发布:linux 查看中断 编辑:程序博客网 时间:2024/05/17 20:00
  <script>
//document.write(parseInt(10*Math.random()));  //输出0~10之间的随机整数

//document.write(Math.floor(Math.random()*10+1));  //输出1~10之间的随机整数

-----------------------------------------

function RndNum(n){
var rnd="";
for(var i=0;i<n;i++)
rnd+=Math.floor(Math.random()*100);
return rnd;

}

   

</script>

<body>

<script>document.write(RndNum(4))</script>

</body>