vb.net随机数生成 vb随机数生成器( 二 )


End Sub
编写一个 VB.NET 程序,产生 100 个 100 以内的随机数,将他们从大到小排序后输出Private Sub Command1_Click()
Dim a(1 To 100) As Integer
Dim i As Integer, j As Integer, k As Integer
For i = 1 To 100'给数组a一百个元素赋值,并换每行十个数字输出来窗体上
a(i) = Int(Rnd * 101)
k = k + 1
Print Tab((k - 1) * 5); a(i);
If k = 10 Then k = 0: Print
Next i
Print
Print
For i = 100 To 2 Step -1'用冒泡排序法对数组进行排序
For j = 1 To i - 1
If a(j)a(j + 1) Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
End If
Next j
Next i
For i = 1 To 100'输出排好序的数组
k = k + 1
Print Tab((k - 1) * 5); a(i);
If k = 10 Then k = 0: Print
Next i
End Sub
vb.net中产生三位正整数的随机数的程序写法'项目:VB中产生在一定正整数范围内vb.net随机数生成的不重复vb.net随机数生成的随机数'作者:qq15495835Private Sub Command1_Click() Max = 100'随机数上限值 Min = 1'随机数下限值 Amount = 10'产生号码数量(数量值应小于随机数上限值-随机数下限值)否则会产生死循环 ReDim a(Amount) Randomize For i = 0 To Amounta(i) = Int((Max - Min + 1) * Rnd + Min)For j = 0 To iIf ij And a(i) = a(j) Then i = i - 1Next Next Text1 = Join(a, vbCrLf)End Sub'请采纳参考!谢谢!
vb.net随机数生成的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vb随机数生成器、vb.net随机数生成的信息别忘了在本站进行查找喔 。

推荐阅读