close

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>亂數不重複</title>
<h2>亂數不重複</h2>

<Script type ="text/javascript">
function add() {
var a=0,b=0,c=0;
var minNum = 0;
var maxNum = 9;

a = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
b = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
c = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
while(b==a)
{b = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;}
while(c==a )
{c = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;}
while(c==b )
{c = Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;}

document.getElementById('c3').value ="亂數:"+a+b+c;
}
</Script>
<input type="text" name="address" id="c3" <br></br>
<input type="button" value="Random" onclick="add()"/>
</head>
<body>
</body>
</html>

11  

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 呆o傻 的頭像
    呆o傻

    trylove0718的部落格

    呆o傻 發表在 痞客邦 留言(0) 人氣()