设计一程序,用随机函数产生30个两位整数(不能有相同的数),按从小到大的顺序排列输出

来源:百度知道 编辑:UC知道 时间:2024/05/27 19:37:43
不好意思是VB

 
 
 

' 注释在底端。
Private Sub Form_Load()
    Const LOWER_LIMIT = 10
    Const UPPER_LIMIT = 99
    Const RANGE = UPPER_LIMIT - LOWER_LIMIT + 1

    On Error Resume Next    ' 注 1

    Dim sortedRandoms As New Collection     ' 注 2
    Randomize   ' 注 3
    Do Until sortedRandoms.Count = 30   ' 注 4
        newRandom = Int(RANGE * Rnd) + LOWER_LIMIT   ' 注 5
        For Each random In sortedRandoms    ' 注 6
            If random > newRandom Then Exit For