mdsk.net
当前位置:首页 >> vB随机生成50到100随机数 >>

vB随机生成50到100随机数

Private Sub Command1_Click() Dim i, max, min, s As Integer max = 0 min = 100 s = 0 Dim a(30) As Integer Text1.Text = "" Text2.Text = "" Text3.Text = "" Randomize Now For i = 1 To 30 a(i) = Int((100 - 50 + 1) * Rnd + 50) If max If min > a(i)

楼上的用的是vbscriptrandomizefor i = 1 to 20 a(i)=int(rnd*(100-50+1))+50next i

Private Sub Form_Activate() Dim a(1 To 20) As Integer, b As Integer, c As Integer, d As Integer, e As Integer Randomize Print "随机数:"; For i = 1 To 20 a(i) = Int(Rnd * 50) + 50 If a(i) > d Then d = a(i) e = e + a(i) Print a(i); Next c = a(1) For i = 2

Dim a(1 To 20) As Integer Private Sub Command1_Click() Cls Scale (0, 0)-(100, 100) For u = 1 To 20 a(u) = Int(Rnd * 50) + 50 b = b + a(u) Print a(u) Next u c = b / 20 For i = 1 To 19 For j = i + 1 To 20 If a(i) > a(j) Then temp = a(i): a(i) = a(j): a(j) =

这个例子可以解决你的问题:Private Sub Command1_Click()Dim i As Integeri = Int((100 - 50 + 1) * Rnd + 50)Print iEnd Sub为了生成某个范围内的随机整数,可使用以下公式:Int((upperbound - lowerbound + 1) * Rnd + lowerbound)这里,upperbound 是随机数范围的上限,而 lowerbound 则是随机数范围的下限.

Private Sub Form_Click() Dim i, j, t, a(1 To 50) Cls Randomize Print "50个随机数:" For i = 1 To 50 a(i) = 1 + Int(100 * Rnd) Print a(i); If i Mod 10 = 0 Then Print Next Rem 用冒泡法排序 For i = 1 To 49 For j = 1 To 50 - i If a(j) > a(j + 1) Then t = a(j

首先介绍Int和Randomize.Int语法格式:Int((upperbound - lowerbound + 1) * Rnd + lowerbound)这里,upperbound 是随机数范围的上限,而 lowerbound 则是随机数范围的下限.为了在不同的运行时能得到不同的随机整数,可以在使用Rnd函

Dim i As Long Dim a(1 To 50) As Integer For i = 1 To 50 a(i) = Int(101 * Rnd + 100) Next 放到数组中

Private Sub Form_click()Dim n(1 To 20) As IntegerDim i, j, ave, tempRandomizeFor i = 1 To 20n(i) = Int((51 * Rnd) + 50)Print n(i)Next iFor j = 1 To 19For i = j + 1 To 20If n(i) >= n(j) Thentemp = n(i)n(i) = n(j)n(j) = tempEnd IfNextNextave = 0For i = 1

Private Sub Command1_Click() Dim a(1 To 50) As Integer Dim n As Integer Randomize For i = 1 To 50 a(i) = Int(Rnd * 100 + 1) If a(i) >= 90 Then Print a(i); n = n + 1 If n Mod 10 = 0 Then Print End If Next iEnd Sub

网站首页 | 网站地图
All rights reserved Powered by www.mdsk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com