VB题 .利用随机函数rnd产生30个10~100之间的整数,再将它们按照由小到大的顺序排列输出
问题描述:
VB题 .利用随机函数rnd产生30个10~100之间的整数,再将它们按照由小到大的顺序排列输出
答
Private Sub Command1_Click()
Dim a(29) As Integer,tmp As Integer
Dim i As Integer,j As Integer
Randomize Time
For i = 0 To 29
a(i) = Int(Rnd * 71) + 30
Next
For i = 0 To 29
For j = i To 29
If a(i) > a(j) Then
tmp = a(i)
a(i) = a(j)
a(j) = tmp
End If
Next
Next
For i = 0 To 29
Print a(i);
If i = 14 Then Print
Next
End Sub