像下面产生了50个随机数:
randomize
dim w(50)
for i=1 to 50
w(i)=rnd()
response.write w(i)
next
但输出的结果很乱,如何对这50个随机数进行排序?(使它按从大到小或从小到大的顺序输出)
谢谢了??
对了,这50个随机数在有些时候会不会出来相同的?
...全文
1778打赏收藏
{求助}在ASP中如何对产生的50个随机数排序??{求助}
在ASP中如何对产生的50个随机数排序?? 像下面产生了50个随机数: randomize dim w(50) for i=1 to 50 w(i)=rnd() response.write w(i) next 但输出的结果很乱,如何对这50个随机数进行排序?(使它按从大到小或从小到大的顺序输出) 谢谢了?? 对了,这50个随机数在有些时候会不会出来相同的?
<SCRIPT LANGUAGE=vbscript >
'洗牌
Dim N,S,D,P
P=54'牌的数量
Set D = CreateObject("Scripting.Dictionary")
do while D.Count<P
Randomize
N=Int(P * Rnd + 1)
if not D.Exists(cstr(N)) then
D.Add cstr(N),cstr(N)
end if
loop
for each K in D.Keys
S=S & K & " "
next
msgbox replace(trim(S)," ",",")
</SCRIPT>
access
select top 5 * from [table] order by rnd(id)
sql server
select top 5 * from [table] order by newid()