给15个数排序(2)

来源:互联网 发布:淘宝号码购买 编辑:程序博客网 时间:2024/06/05 04:30

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

 

1 0
原创粉丝点击