asp随机选取5组彩票的代码

来源:转载

asp随机选取5组彩票

Function rndtest(m_count,r_count) ''参数m_count号码总数,r_count为要取出的号码数
dim x,st,i
i=1
st=""
do while i<=r_count
randomize
x=int(rnd*m_count)+1 ''产生1~m_count的随机数
if i=r_count then
if not instr(st,x)>0 then
st=st&x
i=i+1
end if
else
if not instr(st,x)>0 then
st=st&x&","  ''用,分割
i=i+1
end if
end if
if i>=m_count then
exit do ''如果m_count小于r_count将出现死循环,于是判断并跳出循环
end if
loop
rndtest=st
end function


function sort(ary)'冒泡函数
ck=true
do Until ck = false
ck=false
For f = 0 to UBound(ary) -1
  if clng(ary(f))>clng(ary(f+1)) then
   v1=clng(ary(f))
   v2=clng(ary(f+1))
   ary(f)=v2
   ary(f+1)=v1
   ck=true
  end if
next
loop
sort=ary
end function

for i=0 to 4
Mycount=rndtest(33,7)
MyArray=split(Mycount,",")
newArray=sort(MyArray)
for i2=0 to UBound(newArray)
Response.Write(newArray(i2)&" ")
next
Response.Write("<br>")
next

分享给朋友:
您可能感兴趣的文章:
随机阅读: