ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Bubblesort ªº°g«ä¦b¤å¦r+¼Æ­È®æ¦¡®É?

[µo°Ý] Bubblesort ªº°g«ä¦b¤å¦r+¼Æ­È®æ¦¡®É?

¦U¦ì¤j¤j¡A³o­Ó°ÝÃD§Ú¬d¤FÆZ¤[¤F¦ý©l²×¨S¿ìªk³æ¥ÎVBA¸Ñ¨M(¥Ø«e¥ÎsplitµM«á¦A¥Ñ«á­±¼Æ­È¥ÎBubblesort)¡A¥\¤O¤£°÷...
¦pªG³æ¯Â¥ÎBubblesort±Æ¥X¨Ó¹³Âæ:
javascript:;javascript:;

±`±`¹J¨ì  ¤å¦r+"-"©Î"/"©Î"#" ªº®æ¦¡¡A§xÂZÆZ¤[ªº¡A¦³¤j¤j¤]¹J¹L³oºØ°ÝÃD¶Ü? ³Â·Ð´£ÂI¤@¤U¡A·P¿E¤£ºÉ^^

¹Ï¤ù 20150621124951.png (6.7 KB)

¸Þ²§ªº±Æ¦C

¹Ï¤ù 20150621124951.png

Bubblesort.rar (13.21 KB)

¦^´_ 1# ui123

µ¹§A°Ñ¦Ò¬Ý¬Ý
  1. Sub ex() '®æ¦¡¤Æ¤å¦r¡A±N¼Æ¦rÅܦ¨©T©wªø«×¤å¦r¸É00
  2. Debug.Print Format("62", "0000")
  3. Debug.Print Format("00062", "####")
  4. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# ui123


    ¥ý¤å¦r±Æ§Ç¡A¦A¼Æ¦r±Æ§Ç
À³¸Ó¥i¥H¹F¦¨§A­nªº®ÄªG¡I
  1. Sub Bubblesort()
  2. Dim i, j  As Integer
  3. Dim arr, si, sj, s As Variant
  4. arr = Range("a4:a" & Cells(Rows.Count, 1).End(xlUp).Row)
  5. For i = 1 To UBound(arr)
  6.     For j = i + 1 To UBound(arr)
  7.         If arr(i, 1) > arr(j, 1) Then
  8.             s = arr(i, 1)
  9.             arr(i, 1) = arr(j, 1)
  10.             arr(j, 1) = s
  11.         End If
  12.     Next
  13. Next
  14. For i = 1 To UBound(arr)
  15.     For j = i + 1 To UBound(arr)
  16.             si = Split(arr(i, 1), "-")
  17.             sj = Split(arr(j, 1), "-")
  18.             If si(0) = sj(0) Then
  19.                 If si(1) + 1 > sj(1) + 1 Then '+1¬OÅý"¤å¦r«¬ªº¼Æ¦r"Åܬ°"¼Æ¦r"
  20.                     s = arr(i, 1)
  21.                     arr(i, 1) = arr(j, 1)
  22.                     arr(j, 1) = s
  23.                     End If
  24.             End If
  25.     Next
  26. Next
  27. [a4].Resize(UBound(arr)) = arr
  28. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# ui123

¬O³o¼Ë¶Ü?
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Rng As Range, Sp As Variant
  4.     Set Rng = Range("a4")
  5.     Do While Rng <> ""
  6.         Sp = Rng
  7.         For i = 1 To Len(Rng)
  8.             If Mid(Rng, i, 1) Like "[!A-z]" And Mid(Rng, i, 1) Like "[!0-9]" Then
  9.                 'Mid(Rng, i, 1) ¤£¬O¤å¦r,¼Æ¦r.
  10.                 Sp = Replace(Sp, Mid(Sp, i, 1), ",")  '+"-"©Î"/"©Î"#"  ´À´«¬° ","
  11.             End If
  12.         Next
  13.         Sp = Split(Sp, ",")
  14.         With Rng.Cells(1, 2).Resize(1, UBound(Sp) + 1)
  15.             .Value = Sp
  16.             .Value = .Value
  17.         End With
  18.         Set Rng = Rng.Offset(1)
  19.     Loop
  20. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE
§Ú©ú¤Ñ¥h¤½¥q¸Õ¸Õ¬Ý ^^~ ¥ýÁÂÁÂÅo!

TOP

        ÀR«ä¦Û¦b : ¦Û¤v®`¦Û¤v¡A²ö¹L©ó¶ÃµoµÊ®ð¡C
ªð¦^¦Cªí ¤W¤@¥DÃD