vb产生随机数vb产生随机数
Static Function Shuffle (Lower As Integer, Upper As Integer) As Integer
Static PrimeFactor(10) As Integer Static a As Integer, c As Integer, b As Integer
Static s As Integer, n As Integer Dim i As Integer, j As Integer, k As Integer
Dim m As Intege...
vb产生随机数
Static Function Shuffle (Lower As Integer, Upper As Integer) As Integer
Static PrimeFactor(10) As Integer Static a As Integer, c As Integer, b As Integer
Static s As Integer, n As Integer Dim i As Integer, j As Integer, k As Integer
Dim m As Integer
If (n <> Upper - Lower + 1) Then
n = Upper - Lower + 1
i = 0
n1 = n
k = 2
Do While k <= n1
If (n1 Mod k = 0) Then
If (i = 0 Or PrimeFactor(i) <> k) Then
i = i + 1
PrimeFactor(i) = k
End If
n1 = n1 / k
Else
k = k + 1
End If
Loop
b = 1
For j = 1 To I
b = b * PrimeFactor(j)
Next j
If n Mod 4 = 0 Then b = b * 2
a = b + 1
c = Int(n * .66)
t = True
Do While t
t = False
For j = 1 To I
If ((c Mod PrimeFactor(j) = 0) Or _
(c Mod a = 0)) Then t = True
Next j
If t Then c = c - 1
Loop
Randomize
s = Rnd(n)
End If
s = (a * s + c) Mod n
Shuffle = s + Lower
End Function
µ?ÓÃ?ºÀýÈçÒª?úÉú20?ö1µ?100??Î?ÄÚµÄ??ÏàÍ?µÄËæ?úÊý??
For I = 1 To 20
num(I)=Shuffle(1,100)
next I
本文档为【vb产生随机数】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。