产生一个任意大小的随机数
SELECT ABS(MOD(DBMS_RANDOM.RANDOM,100)) FROM DUAL
产生一个100以内的随机数
SELECT TRUNC(100+900*dbms_random.value) FROM dual
产生一个100~1000之间的随机数
SELECT dbms_random.value FROM dual
产生一个0~1之间的随机数
SELECT dbms_random.value(10,20) FROM dual
产生一个10~20之间的随机数
SELECT dbms_random.normal FROM dual
NORMAL函数返回服从正态分布的一组数。此正态分布标准偏差为1,期望值为0。这个函数返回的数值中有68%是介于-1与+1之间,95%介于-2与+2之间,99%介于-3与+3之间。
RandomizeDim a(20)
Dim s1, s2, s3, s4, s5, s6
s1 = 0: s2 = 0: s3 = 0: s4 = 0: s5 = 0: s6 = 0
For i = 0 To 19
a(i) = Round(100 * Rnd(1))
Print a(i)
Next
For i = 0 To 19
If a(i) >= 50 And a(i) <= 59 Then s1 = s1 + 1
If a(i) >= 60 And a(i) <= 69 Then s2 = s2 + 1
If a(i) >= 70 And a(i) <= 79 Then s3 = s3 + 1
If a(i) >= 80 And a(i) <= 89 Then s4 = s4 + 1
If a(i) >= 90 And a(i) <= 100 Then s5 = s5 + 1
If a(i) <50 Then s6 = s6 + 1
Next
Print "50-59的有:" &s1 &"人"
Print "60-69的有:" &s2 &"人"
Print "70-79的有:" &s3 &"人"
Print "80-89的有:" &s4 &"人"
Print "90-100的有:" &s5 &"人"
Print "小于50的有:" &s6 &"人"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)