|
- Sub ssjss() '2023.6.16 wzq
- Dim i%, j%, s%, r%, L%, arr, brr
- Sheet2.Activate
- r = 8 '[C65536].End(3).Row
- arr = Range("c1:V" & r).Value
- Dim d As Object, d1 As Object
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- L = 20 '定义中奖号任意长度(个数)
-
- '求未开出号(用字典)
- For i = 1 To 80: d(i) = "": Next
- For i = 2 To r
- For j = 1 To L
- If d.exists(Val(arr(i, j))) Then
- d.Remove Val(arr(i, j))
- End If
- Next
- Next
- brr = d.keys
- Call SelectionSort(brr)
- Range("c10").Resize(1, d.Count) = brr
-
- '求连出号(用字典)
- d.RemoveAll
- For i = 3 To r
- For j = 1 To L
- d(Val(arr(i - 1, j))) = ""
- Next
- For j = 1 To L
- If d.exists(Val(arr(i, j))) Then
- d1(arr(i, j)) = ""
- End If
- Next
- d.RemoveAll
- Next
- brr = d1.keys
- Call SelectionSort(brr)
- Call array1to2(brr)
- Range("c11").Resize(UBound(brr) + 1, L) = brr
- '求本期重号(用字典)
- d.RemoveAll: d1.RemoveAll
- For i = r To r
- For j = 1 To L
- d(Val(arr(i - 1, j))) = ""
- Next
- For j = 1 To L
- If d.exists(Val(arr(i, j))) Then
- d1(arr(i, j)) = ""
- End If
- Next
- d.RemoveAll
- Next
- brr = d1.keys
- Call SelectionSort(brr)
- Range("c13").Resize(1, d1.Count) = brr
- '求下期斜连号(用字典)
- d.RemoveAll: d1.RemoveAll
- For i = r To r
- For j = 1 To L
- s = Val(arr(i, j))
- If s = 1 Then
- d(s + 1) = ""
- ElseIf s = 80 Then
- d(s - 1) = ""
- Else
- d(s - 1) = ""
- d(s + 1) = ""
- End If
- Next
- Next
- brr = d.keys
- Call SelectionSort(brr)
- Call array1to2(brr)
- Range("c15").Resize(UBound(brr) + 1, L) = brr
- End Sub
- '选择排序
- Sub SelectionSort(arr)
- Dim i&, j&, vSwap, min&
- For i = 0 To UBound(arr) - 1
- min = i
- For j = i + 1 To UBound(arr)
- If arr(min) > arr(j) Then min = j
- Next
- If min <> i Then
- vSwap = arr(min): arr(min) = arr(i): arr(i) = vSwap
- End If
- Next
- End Sub
- '数组一维变二维
- Sub array1to2(arr)
- Dim i%, j%, L%
- L = UBound(arr) \ 20
- ReDim brr(0 To L, 0 To 19)
- For i = 0 To L
- For j = 0 To 19
- If i * 20 + j > UBound(arr) Then Exit For
- brr(i, j) = arr(i * 20 + j)
- Next
- Next
- arr = brr
- End Sub
复制代码 |
|