- 帖子
- 323
- 主題
- 6
- 精華
- 0
- 積分
- 313
- 點名
- 0
- 作業系統
- xp
- 軟體版本
- 2k
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2015-6-24
- 最後登錄
- 2026-1-5
|
Sub GO_______________()
MsgBox Join(數字歸類(Array(246517, 246518, 246519), 1), vbCrLf)
MsgBox Join(數字歸類(Array(246299, 246217, 246517, 246518, 246519), 2), vbCrLf)
End Sub
Public Function 數字歸類(NumAR, ByVal 位數 As Long)
' 位數 need >= 0
Set c_max = CreateObject("Scripting.Dictionary")
Set c_min = CreateObject("Scripting.Dictionary")
For Each n In NumAR
root = n \ (10 ^ 位數)
n = n Mod (10 ^ 位數)
If Not c_max.exists(root) Then
c_max(root) = n
c_min(root) = n
End If
If n > c_max(root) Then c_max(root) = n
If n < c_min(root) Then c_min(root) = n
Next
For Each root In c_max
c_max(root) = root & "(" & c_min(root) & "-" & c_max(root) & ")"
Next
數字歸類 = c_max.items
End Function |
|