mdsk.net
当前位置:首页 >> vB产生10到99的随机数 >>

vB产生10到99的随机数

Private Sub command1_click()Dim a() As IntegerRandomizen = -1Don = n + 1ReDim Preserve a(n)a(n) = Int(Rnd * 90) + 10Print a(n);If (n + 1) Mod 10 = 0 Then PrintIf n > 0 Thenf = Falseb = a(n) \ 10 + (a(n) Mod 10) * 10For i = 0 To n - 1If b = a(i)

Option Base 1Private Sub Form_click()Dim num(10, 10) As IntegerDim sum As DoubleRandomizeFor i = 1 To 10 For j = 1 To 10 num(i, j) = Int(Rnd * 90 + 10) Print num(i, j); sum = sum + num(i, j) Next j PrintNext iPrint "和为" & sumEnd Sub

'方法1,不是你的方法,呵呵,直接产生10个随机数记性排列,谁知道是怎么产生的 ,呵呵.randomize dim a(9) for i=0 to 9 a(i)=int(rnd*300+101) next i for j = 0 to 8 for k = 0 to 8 - j if a(k) > a(k + 1) then t = a(k) a(k) = a(k + 1) a(k + 1) = t end if next

for i=1 to 10 print int(rnd *( 99 -10 + 1) + 10)next i

vb 产生随机数的公式 (上界-下界+1)*rnd+下界 你的题目就应该是 (99-10+1)*rnd +10 一般用rnd的时候还要在前面加一条 randomize 初始化随机种 子 随机数产生的不是正整 数,是带小数的整数.如果你要正整数就用int函数 int((99-10+1)*rnd +10)

最大数=&quotDim i As IntegerDim min As IntegerDim max As IntegerDim m As Integermin = 100max = 0For i = 0 To 9 m = Int(Rnd * 100) Print m If min > m Then min = m If max 评论0 0 0

Private Sub Command1_Click()Dim m(9) As IntegerDim a As IntegerDim i As IntegerDim j As Integera = 0For i = 0 To 9 m(i) = 10 + Int(Rnd * 89)NextText1.Text = m(0) & "," & m(1) & "," & m(2) & "," & m(3) & "," & m(4) & "," & m(5) &

Private Sub Command1_Click()Dim a(10 To 99) As IntegerFor i = 1 To 1000 x = Int(90 * Rnd()) + 10 '产生10~99的随机数 a(x) = a(x) + 1 '统计此数个数Next iMax = -1For i = 10 To 99 If a(i) > Max Then Max = a(i) '找出个数最多的数Next iFor i = 10 To 99 If a(i) = Max Then Print i; '输出所有个数为Max的随机数Next iPrintEnd Sub

以下是关键代码,其他的我就不打了 dim i as Integer dim max as integer dim min as integer dim temp as integer '定义变量,i为循环变量,max为最大数,min为最小数,temp为每一次生成数时使用的临时变量 temp=Int(90*rnd()+10) max=temp

private sub command1_click() dim a(20) as integer print "20个1~1000之间的随机数:" randomize for i = 1 to 20 a(i) = int(rnd * 1001) print tab(((i - 1) mod 10 + 1) * 5); a(i); if i mod 10 = 0 then print next i print print "其中的素数有:" for i = 1 to

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