从0-22 抽出 5个数 这几个数不能相同。怎么版。啊。。

随机 啊。。。

---------------------------------------------------------------

1   
2dim a(5)   
3for i=1 to 5   
4a(i)=Int((22 - 0 + 1) * Rnd + 0)   
5next   
6for i=1 to 5   
7response.write a(i)&"

<p>"
next

 1\---------------------------------------------------------------   
 2  
 3<script language="vbscript">   
 4<!--   
 5  
 6Dim i,num,ary(4),str   
 7  
 8str =""   
 9Randomize()   
10  
11  
12for i = 0 to 4   
13  
14num = (100*rnd) mod 23   
15do while numInAry(num,ary)   
16num = (100*rnd) mod 23   
17loop   
18ary(i) = num   
19str = str & num & ","   
20next   
21  
22str = left(str,len(str)-1)   
23alert(str)   
24  
25  
26  
27function numInAry(num,ary)   
28Dim i   
29for i = lbound(ary) to Ubound(ary)   
30if num = ary(i) then   
31numInAry = true   
32exit function   
33end if   
34next   
35numInAry = false   
36  
37End function   
38  
39  
40//-->   
41</script>   
42  
43  
44  
45\---------------------------------------------------------------   
46  

dim a(5)
for i=1 to 5
a(i)=Int((22 - 3 + 1) * Rnd + 0)
next
for i=1 to 5
response.write a(i)&amp;"<p>"
next

Published At
Categories with Web编程
Tagged with
comments powered by Disqus