1月14

从数组随机取出几个不同数

| |
12:47 ASP  From: 本站原创
从数组随机取出几个不相同数,如何从一组数据中随机取出几个不同的数,有点像摇奖和彩票类

<%    
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
阅读(4375) | 评论(1) | 引用(0)
tommyhuc.cn网友
2012/04/21 14:46
走过路过,不能错过!!!!!!!!!!!!!!!!!
tommyhu 回复于 2012/04/21 21:53
谢谢捧场
分页: 1/1 第一页 1 最后页
在此留下酱油瓶-:)
表情
emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我

您的大名(例如:小明) : 

密码(可不填) :  游客无需密码

网址 (可不填) : 

电邮 (可不填) :  [注册]