asp程序,在1-33之间随机取6个数为一组,都显示出来,请问怎么写出代码?

来源:百度知道 编辑:UC知道 时间:2024/05/18 00:34:09

<%
function random()
dim a
do while a=0
randomize
a=cint(rnd*10000) mod 34
loop
random=a
end function
dim arr(6)
for i=1 to 6
arr(i)=random
next
for i=1 to 6
response.write arr(i)
response.write "<br />"
next
%>

Dim nMin, nMax, nCount, sResult, i, tmp
nMin = 1
nMax = 33
nCount = 6

Randomize
sResult = ""
For I = 1 To nCount
If sResult <> "" Then sResult = sResult & " "
Do
tmp = Cint(Rnd() * (nMax - nMin + 1)) + nMin
Loop While(Instr(" " & sResult, " " & tmp & " ") > 0)
sResult = sResult & tmp
Next
Response.Write(sResult)