1个回答
展开全部
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无重复随机数生成器</title>
</head>
<body>
<script language=vbscript>
Function GetRnd()
lowerNum=1
upperNum = document.lotto.maxnum.value
Dim unit,RndNum,Fun_X
unit = upperNum - lowerNum
Redim MyArray(unit)
Redim outmarr(unit)
For Fun_I=0 To unit
myArray(Fun_I)= lowerNum + Fun_I
Next
For Fun_I=0 To round(unit)
RndNum = getRndNumber(Fun_I,unit)
Fun_X = myArray(RndNum)
myArray(RndNum)=myArray(Fun_I)
myArray(Fun_I)=Fun_X
Next
For i=0 to upperNum
document.write MyArray(i)&"<br>"
Next
End Function
Function getRndNumber(lowerbound,upperbound)
Randomize
getRndNumber=Int((upperbound-lowerbound+1)*Rnd+lowerbound)
End Function
</script>
<form name="lotto">
<table width=100% border=0>
<tr>
<td align=center>
<br>请输入要产生的最大数字: <input type=text name=maxnum value="100" size=4 maxlength=4><br><br><br><br>
<input type=button value="产生随机数" onClick="GetRnd()">
<p>
</td>
</tr>
</table>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无重复随机数生成器</title>
</head>
<body>
<script language=vbscript>
Function GetRnd()
lowerNum=1
upperNum = document.lotto.maxnum.value
Dim unit,RndNum,Fun_X
unit = upperNum - lowerNum
Redim MyArray(unit)
Redim outmarr(unit)
For Fun_I=0 To unit
myArray(Fun_I)= lowerNum + Fun_I
Next
For Fun_I=0 To round(unit)
RndNum = getRndNumber(Fun_I,unit)
Fun_X = myArray(RndNum)
myArray(RndNum)=myArray(Fun_I)
myArray(Fun_I)=Fun_X
Next
For i=0 to upperNum
document.write MyArray(i)&"<br>"
Next
End Function
Function getRndNumber(lowerbound,upperbound)
Randomize
getRndNumber=Int((upperbound-lowerbound+1)*Rnd+lowerbound)
End Function
</script>
<form name="lotto">
<table width=100% border=0>
<tr>
<td align=center>
<br>请输入要产生的最大数字: <input type=text name=maxnum value="100" size=4 maxlength=4><br><br><br><br>
<input type=button value="产生随机数" onClick="GetRnd()">
<p>
</td>
</tr>
</table>
</form>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询