<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>隨機產生亂數</title>
<Script type ="text/javascript">
var a=0,b=0,c=0;
var minNum = 0;
var maxNum = 6;
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;
if(b==a)
{b=b+1;}
if(c==a)
{c=c+2;}
if(c==b)
{c=c+1;}
document.write("亂數a:",+a,"亂數b:",+b,"亂數c:",+c);
</Script>
</head>
<body>
<h2>亂數不重複</h2>
</body>
</html>
2016年6月3日 星期五
2016年6月2日 星期四
亂數不重複
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>隨機產生亂數</title>
<Script type ="text/javascript">
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.write("亂數a:",+a,"亂數b:",+b,"亂數c:",+c);
</Script>
</head>
<body>
<h2>亂數不重複</h2>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>隨機產生亂數</title>
<Script type ="text/javascript">
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.write("亂數a:",+a,"亂數b:",+b,"亂數c:",+c);
</Script>
</head>
<body>
<h2>亂數不重複</h2>
</body>
</html>
亂數可重複
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>隨機產生亂數</title>
<Script type ="text/javascript">
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;
document.write("亂數a:",+a,"亂數b:",+b,"亂數c:",+c);
</Script>
</head>
<body>
<h2>document.write用法</h2>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>隨機產生亂數</title>
<Script type ="text/javascript">
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;
document.write("亂數a:",+a,"亂數b:",+b,"亂數c:",+c);
</Script>
</head>
<body>
<h2>document.write用法</h2>
</body>
</html>
訂閱:
文章 (Atom)