用VB在1-100中产生10个随机整数,按从小到大的顺序排列 如题..求代码
问题描述:
用VB在1-100中产生10个随机整数,按从小到大的顺序排列 如题..求代码
答
Dim MyValue(10) As Integer
Dim i,j,p As Integer
For i = 0 To 9
Randomize
MyValue(i) = Int((100 * Rnd) + 1)
Next
For i = 0 To 9
For j = i + 1 To 10
If MyValue(i) > MyValue(j) Then
p = MyValue(i)
MyValue(i) = MyValue(j)
MyValue(j) = p
End If
Next
Next
For i = 0 To 9
Print MyValue(i)
Next i