- ©«¤l
- 228
- ¥DÃD
- 73
- ºëµØ
- 2
- ¿n¤À
- 333
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 10
- ³nÅ骩¥»
- Office 2000, 2019
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¹ü¤Æ¿¤
- µù¥U®É¶¡
- 2013-7-18
- ³Ì«áµn¿ý
- 2024-10-13
|
³Ì«áÀu¤Æ¡A±q쥻ªº0.198¬í¡÷0.089¬í- Option Explicit
- Option Base 1
- Option Compare Text
- Public Sub S_¤Gºû°}¦C§Ö³t´¡¤Jéw»¼¼W±Æ§Ç_01(ByRef ì©l¤Gºû°}¦C As Variant, ByVal ±Æ§Çºû«× As Long, ByVal ±Æ§ÇÁäÈ As Long, ByVal °_ As Long, ByVal ¨´ As Long)
- On Error Resume Next
-
- If °_ >= ¨´ Then
- Exit Sub
- End If
-
- '------------------------------------------------------
-
- Dim X As Long
- Dim Y As Long
-
- Dim Â^¨ú¦¨¤@ºû°}¦C As Variant
- Dim ¯Á¤Þ°}¦C() As Long
-
- '------------------------------------------------------
-
- ReDim Â^¨ú¦¨¤@ºû°}¦C(°_ To ¨´) As Variant
- ReDim ¯Á¤Þ°}¦C(°_ To ¨´) As Long
-
- If ±Æ§Çºû«× = 1 Then
- For X = °_ To ¨´
- Â^¨ú¦¨¤@ºû°}¦C(X) = ì©l¤Gºû°}¦C(X, ±Æ§ÇÁäÈ)
- ¯Á¤Þ°}¦C(X) = X
- Next X
- Else
- For Y = °_ To ¨´
- Â^¨ú¦¨¤@ºû°}¦C(Y) = ì©l¤Gºû°}¦C(±Æ§ÇÁäÈ, Y)
- ¯Á¤Þ°}¦C(Y) = Y
- Next Y
- End If
-
- '------------------------------------------------------
-
- ¤Gºû°}¦C§Ö³t´¡¤Jéw»¼¼W±Æ§Ç Â^¨ú¦¨¤@ºû°}¦C, ¯Á¤Þ°}¦C, °_, ¨´
-
- '------------------------------------------------------
-
- Dim ½Æ»sì©l¤Gºû°}¦C As Variant
-
- ½Æ»sì©l¤Gºû°}¦C = ì©l¤Gºû°}¦C
-
- If ±Æ§Çºû«× = 1 Then
- For X = °_ To ¨´
- For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
- ì©l¤Gºû°}¦C(X, Y) = ½Æ»sì©l¤Gºû°}¦C(¯Á¤Þ°}¦C(X), Y)
- Next Y
- Next X
- Else
- For Y = °_ To ¨´
- For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
- ì©l¤Gºû°}¦C(X, Y) = ½Æ»sì©l¤Gºû°}¦C(X, ¯Á¤Þ°}¦C(Y))
- Next X
- Next Y
- End If
- End Sub
- Public Sub ¤Gºû°}¦C§Ö³t´¡¤Jéw»¼¼W±Æ§Ç(ByRef ì©l¤@ºû°}¦C As Variant, ByRef ¯Á¤Þ°}¦C() As Long, ByVal °_ As Long, ByVal ¨´ As Long)
- On Error Resume Next
-
- If °_ >= ¨´ Then
- Exit Sub
- End If
-
- '------------------------------------------------------
-
- Dim X As Long
- Dim Y As Long
- Dim S As Long
- Dim M As Long
- Dim E As Long
- Dim N As Long
-
- Dim ¼È¦s As Variant
- Dim ¯Á¤Þ¼È¦s As Long
- Dim °ò·Ç As Variant
-
- '------------------------------------------------------
-
- If ¨´ - °_ < 16 Then
- For X = °_ + 1 To ¨´
- ¼È¦s = ì©l¤@ºû°}¦C(X)
- ¯Á¤Þ¼È¦s = ¯Á¤Þ°}¦C(X)
-
- For Y = X - 1 To °_ Step -1
- If ¼È¦s >= ì©l¤@ºû°}¦C(Y) Then
- Exit For
- End If
-
- ì©l¤@ºû°}¦C(Y + 1) = ì©l¤@ºû°}¦C(Y)
- ¯Á¤Þ°}¦C(Y + 1) = ¯Á¤Þ°}¦C(Y)
- Next Y
-
- ì©l¤@ºû°}¦C(Y + 1) = ¼È¦s
- ¯Á¤Þ°}¦C(Y + 1) = ¯Á¤Þ¼È¦s
- Next X
- Else
- Dim °ò·Ç°}¦C(3) As Variant
-
- °ò·Ç°}¦C(1) = ì©l¤@ºû°}¦C(°_)
- °ò·Ç°}¦C(2) = ì©l¤@ºû°}¦C((°_ + ¨´) \ 2)
- °ò·Ç°}¦C(3) = ì©l¤@ºû°}¦C(¨´)
-
- For X = 2 To 3
- ¼È¦s = °ò·Ç°}¦C(X)
-
- For Y = X - 1 To 1 Step -1
- If ¼È¦s >= °ò·Ç°}¦C(Y) Then
- Exit For
- End If
-
- °ò·Ç°}¦C(Y + 1) = °ò·Ç°}¦C(Y)
- Next Y
-
- °ò·Ç°}¦C(Y + 1) = ¼È¦s
- Next X
-
- °ò·Ç = °ò·Ç°}¦C(2)
-
- '------------------------------------------------------
-
- Dim °_°}¦C As Variant
- Dim °ò°}¦C As Variant
- Dim ¨´°}¦C As Variant
- Dim ¯Á¤Þ°_°}¦C() As Long
- Dim ¯Á¤Þ°ò°}¦C() As Long
- Dim ¯Á¤Þ¨´°}¦C() As Long
-
- ReDim °_°}¦C(¨´ - °_) As Variant
- ReDim °ò°}¦C(¨´ - °_ + 1) As Variant
- ReDim ¨´°}¦C(¨´ - °_) As Variant
- ReDim ¯Á¤Þ°_°}¦C(¨´ - °_) As Long
- ReDim ¯Á¤Þ°ò°}¦C(¨´ - °_ + 1) As Long
- ReDim ¯Á¤Þ¨´°}¦C(¨´ - °_) As Long
-
- S = 0
- M = 0
- E = 0
- For X = °_ To ¨´
- ¼È¦s = ì©l¤@ºû°}¦C(X)
- ¯Á¤Þ¼È¦s = ¯Á¤Þ°}¦C(X)
-
- If ¼È¦s < °ò·Ç Then
- S = S + 1
- °_°}¦C(S) = ¼È¦s
- ¯Á¤Þ°_°}¦C(S) = ¯Á¤Þ¼È¦s
- ElseIf ¼È¦s = °ò·Ç Then
- M = M + 1
- °ò°}¦C(M) = ¼È¦s
- ¯Á¤Þ°ò°}¦C(M) = ¯Á¤Þ¼È¦s
- Else
- E = E + 1
- ¨´°}¦C(E) = ¼È¦s
- ¯Á¤Þ¨´°}¦C(E) = ¯Á¤Þ¼È¦s
- End If
- Next X
-
- '------------------------------------------------------
-
- If S > 1 Then
- ¤Gºû°}¦C§Ö³t´¡¤Jéw»¼¼W±Æ§Ç °_°}¦C, ¯Á¤Þ°_°}¦C, 1, S
- End If
-
- If E > 1 Then
- ¤Gºû°}¦C§Ö³t´¡¤Jéw»¼¼W±Æ§Ç ¨´°}¦C, ¯Á¤Þ¨´°}¦C, 1, E
- End If
-
- '------------------------------------------------------
-
- N = °_ - 1
- For X = 1 To S
- N = N + 1
- ì©l¤@ºû°}¦C(N) = °_°}¦C(X)
- ¯Á¤Þ°}¦C(N) = ¯Á¤Þ°_°}¦C(X)
- Next X
-
- For X = 1 To M
- N = N + 1
- ì©l¤@ºû°}¦C(N) = °ò°}¦C(X)
- ¯Á¤Þ°}¦C(N) = ¯Á¤Þ°ò°}¦C(X)
- Next X
-
- For X = 1 To E
- N = N + 1
- ì©l¤@ºû°}¦C(N) = ¨´°}¦C(X)
- ¯Á¤Þ°}¦C(N) = ¯Á¤Þ¨´°}¦C(X)
- Next X
- End If
- End Sub
½Æ»s¥N½X |
|