dim n(50)
c=20
c=Cint(c)
for i=1 to c
Randomize
n(i)=Int(j* Rnd+1)
for q=1 to i
if n(i)=n(q-1) then
n(i)=q+1
end if
next
response.write n(i)&"<br>"
next
...全文
3146打赏收藏
从数组中随机抽取不重复的数
我想从数组中随机抽取不重复的20个数,为什么总是有重复的呀不明白 dim n(50) c=20 c=Cint(c) for i=1 to c Randomize n(i)=Int(j* Rnd+1) for q=1 to i if n(i)=n(q-1) then n(i)=q+1 end if next response.write n(i)&"" next