1月14
从数组随机取出几个不相同数,如何从一组数据中随机取出几个不同的数,有点像摇奖和彩票类
<%
function showrnd(x,y)
sjyanchu=array("2356","1863","1978","2018","2093","1881","1764","1960") '定义数组,,页面刷新更新显示
if y<x then
exit function
end if
redim n(x)
dim i,q
dim isok
for i=1 to x
Randomize
n(i)=round((y-1)* Rnd)+1
isok=false
do while not isok
for q=1 to i
if n(i)=n(q-1) then
n(i)=Int((y-1)* Rnd)+1
isok=false
exit for
end if
isok=true
next
loop
response.Write sjyanchu(n(i)-1)&“<br/>” '输出
next
end function
call showrnd(4,8) ‘从8个中随机取出4个
%>
最后编辑: tommyhu 编辑于2010/01/14 12:58
<%
function showrnd(x,y)
sjyanchu=array("2356","1863","1978","2018","2093","1881","1764","1960") '定义数组,,页面刷新更新显示
if y<x then
exit function
end if
redim n(x)
dim i,q
dim isok
for i=1 to x
Randomize
n(i)=round((y-1)* Rnd)+1
isok=false
do while not isok
for q=1 to i
if n(i)=n(q-1) then
n(i)=Int((y-1)* Rnd)+1
isok=false
exit for
end if
isok=true
next
loop
response.Write sjyanchu(n(i)-1)&“<br/>” '输出
next
end function
call showrnd(4,8) ‘从8个中随机取出4个
%>
最后编辑: tommyhu 编辑于2010/01/14 12:58
tommyhuc.cn网友
2012/04/21 14:46
走过路过,不能错过!!!!!!!!!!!!!!!!!
tommyhu 回复于 2012/04/21 21:53
谢谢捧场
分页: 1/1
1
1

正则表达式学习资料.rar打包下载
超雷人的nobody舞蹈





