- ©«¤l
- 552
- ¥DÃD
- 3
- ºëµØ
- 0
- ¿n¤À
- 578
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2015-2-8
- ³Ì«áµn¿ý
- 2024-7-9
|
¦^´_ 1# ui123
¥ý¤å¦r±Æ§Ç¡A¦A¼Æ¦r±Æ§Ç
À³¸Ó¥i¥H¹F¦¨§Anªº®ÄªG¡I- Sub Bubblesort()
- Dim i, j As Integer
- Dim arr, si, sj, s As Variant
- arr = Range("a4:a" & Cells(Rows.Count, 1).End(xlUp).Row)
- For i = 1 To UBound(arr)
- For j = i + 1 To UBound(arr)
- If arr(i, 1) > arr(j, 1) Then
- s = arr(i, 1)
- arr(i, 1) = arr(j, 1)
- arr(j, 1) = s
- End If
- Next
- Next
- For i = 1 To UBound(arr)
- For j = i + 1 To UBound(arr)
- si = Split(arr(i, 1), "-")
- sj = Split(arr(j, 1), "-")
- If si(0) = sj(0) Then
- If si(1) + 1 > sj(1) + 1 Then '+1¬OÅý"¤å¦r«¬ªº¼Æ¦r"Åܬ°"¼Æ¦r"
- s = arr(i, 1)
- arr(i, 1) = arr(j, 1)
- arr(j, 1) = s
- End If
- End If
- Next
- Next
- [a4].Resize(UBound(arr)) = arr
- End Sub
½Æ»s¥N½X |
|