返回列表 上一主題 發帖

排序陣列的方法

Option Explicit

Sub test()
     
    Dim rbc6(5) As Double

     rbc6(0) = 5
     rbc6(1) = 6
     rbc6(2) = 3
     rbc6(3) = 111
     rbc6(4) = 2
     rbc6(5) = 1

    Call BubbleSort(rbc6)
     
End Sub

Sub BubbleSort(MyArray() As Double)
     
    Dim First           As Integer
    Dim Last            As Integer
    Dim i               As Integer
    Dim j               As Integer
    Dim Temp            As Double
    Dim List            As Double
     
    First = LBound(MyArray)
    Last = UBound(MyArray)
    For i = First To Last - 1
        For j = i + 1 To Last
            If MyArray(i) > MyArray(j) Then
                Temp = MyArray(j)
                MyArray(j) = MyArray(i)
                MyArray(i) = Temp
            End If
        Next j
    Next i
   
End Sub
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

        靜思自在 : 對父母要知恩,感恩、報恩。
返回列表 上一主題