给15个数排序(2)

Private Sub Command1_Click()
Cls
Dim n As Integer

Dim s(15) As Integer
n = 1
While n <= 15
    s(n) = Int(Rnd * 1000)
    n = n + 1
Wend

Dim t As Integer
m = 1
While m <= 14
n = 1
    While n <= 15 - m
        If s(n) < s(n + 1) Then
        t = s(n)
        s(n) = s(n + 1)
        s(n + 1) = t
    End If
    n = n + 1
Wend
m = m + 1
Wend
n = 1
While n <= 15
    Print s(n)
    n = n + 1
Wend
   
End Sub

 

你可能感兴趣的:(给15个数排序(2))