20 个解决方案
#1
关注
#2
用数组,至于几维数组,要看你是多少选多少。
删掉不可能得大奖的可能,这个条件要自己设。
删掉不可能得大奖的可能,这个条件要自己设。
#3
定义一个13*3的数组,然后在数组里面玩.
#4
最好是在算法上用多线程,还有就是在数组的设计上不一定就是用13*3的,可以用别的思路
比如做出一个3维的数组
比如做出一个3维的数组
#5
我觉得最好是用数据库来实现
这样可以保留一些历史数据
并且从历史数据里面找出一些规律来
这样可以保留一些历史数据
并且从历史数据里面找出一些规律来
#6
可以用一些条件过滤,参考一些现成的软件
#7
我个人觉得,直接用随机数字分析,旋转矩阵原理过滤,缩水.这是经过科学证明的
#8
我自己的设想是通过数据库来处理,但难道需要我生成190多万中可能吗,那样,我的数据库太过于庞大,如果用数组,用3*13的二维数组里利用条件过滤,怎样对数组进行排除?
#9
随机产生若干不重复的数:
Public Static Sub rand()
Dim count As Integer
Dim intNum As Integer
Dim num As Integer
num = 30’所要的最大数字
For k = 1 To 7‘要的随机数的个数
count = count + 1
Randomize
intNum = Int((num * Rnd) + 1)
If count <> 1 Then
For i = 1 To count - 1
Do Until arrnum(i) <> intNum
If arrnum(i) = intNum Then
intNum = Int((num * Rnd) + 1)
i = 1
End If
Loop
Next i
End If
arrnum(k) = intNum
If count = 7 Then
count = 0
Exit Sub
End If
Next k
End Sub
Public Static Sub rand()
Dim count As Integer
Dim intNum As Integer
Dim num As Integer
num = 30’所要的最大数字
For k = 1 To 7‘要的随机数的个数
count = count + 1
Randomize
intNum = Int((num * Rnd) + 1)
If count <> 1 Then
For i = 1 To count - 1
Do Until arrnum(i) <> intNum
If arrnum(i) = intNum Then
intNum = Int((num * Rnd) + 1)
i = 1
End If
Loop
Next i
End If
arrnum(k) = intNum
If count = 7 Then
count = 0
Exit Sub
End If
Next k
End Sub
#10
三种常用的排序方法:
Sub BubbleSortNumbers(iArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lTemp As Long
For lLoop1 = UBound(iArray) To LBound(iArray) Step -1
For lLoop2 = LBound(iArray) + 1 To lLoop1
If iArray(lLoop2 - 1) > iArray(lLoop2) Then
lTemp = iArray(lLoop2 - 1)
iArray(lLoop2 - 1) = iArray(lLoop2)
iArray(lLoop2) = lTemp
End If
Next lLoop2
Next lLoop1
End Sub
Sub SelectionSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lMin As Long
Dim lTemp As Long
For lLoop1 = LBound(vArray) To UBound(vArray) - 1
lMin = lLoop1
For lLoop2 = lLoop1 + 1 To UBound(vArray)
If vArray(lLoop2) < vArray(lMin) Then lMin = lLoop2
Next lLoop2
lTemp = vArray(lMin)
vArray(lMin) = vArray(lLoop1)
vArray(lLoop1) = lTemp
Next lLoop1
End Sub
Sub ShellSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lHold As Long
Dim lHValue As Long
Dim lTemp As Long
lHValue = LBound(vArray)
Do
lHValue = 3 * lHValue + 1
Loop Until lHValue > UBound(vArray)
Do
lHValue = lHValue / 3
For lLoop1 = lHValue + LBound(vArray) To UBound(vArray)
lTemp = vArray(lLoop1)
lHold = lLoop1
Do While vArray(lHold - lHValue) > lTemp
vArray(lHold) = vArray(lHold - lHValue)
lHold = lHold - lHValue
If lHold < lHValue Then Exit Do
Loop
vArray(lHold) = lTemp
Next lLoop1
Loop Until lHValue = LBound(vArray)
End Sub
Sub BubbleSortNumbers(iArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lTemp As Long
For lLoop1 = UBound(iArray) To LBound(iArray) Step -1
For lLoop2 = LBound(iArray) + 1 To lLoop1
If iArray(lLoop2 - 1) > iArray(lLoop2) Then
lTemp = iArray(lLoop2 - 1)
iArray(lLoop2 - 1) = iArray(lLoop2)
iArray(lLoop2) = lTemp
End If
Next lLoop2
Next lLoop1
End Sub
Sub SelectionSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lMin As Long
Dim lTemp As Long
For lLoop1 = LBound(vArray) To UBound(vArray) - 1
lMin = lLoop1
For lLoop2 = lLoop1 + 1 To UBound(vArray)
If vArray(lLoop2) < vArray(lMin) Then lMin = lLoop2
Next lLoop2
lTemp = vArray(lMin)
vArray(lMin) = vArray(lLoop1)
vArray(lLoop1) = lTemp
Next lLoop1
End Sub
Sub ShellSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lHold As Long
Dim lHValue As Long
Dim lTemp As Long
lHValue = LBound(vArray)
Do
lHValue = 3 * lHValue + 1
Loop Until lHValue > UBound(vArray)
Do
lHValue = lHValue / 3
For lLoop1 = lHValue + LBound(vArray) To UBound(vArray)
lTemp = vArray(lLoop1)
lHold = lLoop1
Do While vArray(lHold - lHValue) > lTemp
vArray(lHold) = vArray(lHold - lHValue)
lHold = lHold - lHValue
If lHold < lHValue Then Exit Do
Loop
vArray(lHold) = lTemp
Next lLoop1
Loop Until lHValue = LBound(vArray)
End Sub
#11
分解成小组合:
Sub a(ByRef theArray() As String, ByVal num As Long)
Dim pos() As Long
Dim i As Long
Dim tmp As String
If num = 0 Then Exit Sub
If num > UBound(theArray) Then num = UBound(theArray)
ReDim pos(num - 1)
For i = 0 To num - 1
pos(i) = i
Next i
Do
tmp = ""
For i = 0 To num - 1
tmp = tmp & theArray(pos(i))
Next i
Print tmp
Loop While Not (b(pos(), num - 1, UBound(theArray)) < 0)
End Sub
Function b(ByRef thePosArray() As Long, ByVal currentPos As Long, ByVal max As Long) As Long
Dim i As Long
b = currentPos
If currentPos < 0 Then Exit Function
thePosArray(currentPos) = thePosArray(currentPos) + 1
For i = currentPos + 1 To UBound(thePosArray)
thePosArray(i) = thePosArray(i - 1) + 1
Next i
If thePosArray(UBound(thePosArray)) > max Then
b = b(thePosArray, currentPos - 1, max)
End If
End Function
Private Sub Command1_Click()
Dim x(8) As String
Dim xx
Cls
x(0) = "a"
x(1) = "b"
x(2) = "c"
x(3) = "d"
x(4) = "e"
x(5) = "f"
x(6) = "g"
x(7) = "h"
x(8) = "i"
Call a(x(), 6)
End Sub
以下程序用以求数组的交、并、补:
Function n(Array1 As Variant, Array2 As Variant) As Variant()
'交集
Dim ArrayN() As Variant
Dim i As Long, j As Long
Dim count As Long
ReDim ArrayN(IIf(UBound(Array1) > UBound(Array2), UBound(Array1), UBound(Array2)))
For i = 0 To UBound(Array1)
For j = 0 To UBound(Array2)
If Array1(i) = Array2(j) Then
ArrayN(count) = Array1(i)
count = count + 1
Exit For
End If
Next j
Next i
If count > 0 Then
ReDim Preserve ArrayN(count - 1)
n = ArrayN
End If
End Function
Function u(Array1 As Variant, Array2 As Variant) As Variant()
'并集
Dim ArrayU() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
ReDim Preserve ArrayU(UBound(Array1) + UBound(Array2) + 1)
For i = 0 To UBound(Array1)
ArrayU(i) = Array1(i)
Next i
count = UBound(Array1) + 1
For i = 0 To UBound(Array2)
flag = False
For j = 0 To UBound(Array1)
If Array2(i) = Array1(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayU(count) = Array2(i)
count = count + 1
End If
Next i
ReDim Preserve ArrayU(count - 1)
u = ArrayU
End Function
Function s(ArrayAll As Variant, ArraySub As Variant) As Variant()
'补集
Dim ArrayS() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
If UBound(ArrayAll) - UBound(ArraySub) = 0 Then Exit Function
ReDim ArrayS(UBound(ArrayAll) - UBound(ArraySub) - 1)
For i = 0 To UBound(ArrayAll)
flag = False
For j = 0 To UBound(ArraySub)
If ArrayAll(i) = ArraySub(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayS(count) = ArrayAll(i)
count = count + 1
End If
Next i
s = ArrayS
End Function
旋转矩阵原理 :
在数学上一个复式投注单假设有n个三选,m个双选,其中n+m<=13,所有的投注单构成了一个集合C(n,m),C(n,m)共有3的n次方乘以2的m次方个元素,每一个元素可以表示成一个13位长的三重码,在组合数学中已经证明存在至少一个C(n,m)的子集K(n,m),每一个C(n,m)中的元素,都存在一个K(n,m)中的元素,他们之间仅有1位的差别,即所谓的汉明距离(Hamming Distance)等于1。满足上述条件的最小子集K(n,m)称为问题的一个最优解
这是足彩的缩水原理
Sub a(ByRef theArray() As String, ByVal num As Long)
Dim pos() As Long
Dim i As Long
Dim tmp As String
If num = 0 Then Exit Sub
If num > UBound(theArray) Then num = UBound(theArray)
ReDim pos(num - 1)
For i = 0 To num - 1
pos(i) = i
Next i
Do
tmp = ""
For i = 0 To num - 1
tmp = tmp & theArray(pos(i))
Next i
Print tmp
Loop While Not (b(pos(), num - 1, UBound(theArray)) < 0)
End Sub
Function b(ByRef thePosArray() As Long, ByVal currentPos As Long, ByVal max As Long) As Long
Dim i As Long
b = currentPos
If currentPos < 0 Then Exit Function
thePosArray(currentPos) = thePosArray(currentPos) + 1
For i = currentPos + 1 To UBound(thePosArray)
thePosArray(i) = thePosArray(i - 1) + 1
Next i
If thePosArray(UBound(thePosArray)) > max Then
b = b(thePosArray, currentPos - 1, max)
End If
End Function
Private Sub Command1_Click()
Dim x(8) As String
Dim xx
Cls
x(0) = "a"
x(1) = "b"
x(2) = "c"
x(3) = "d"
x(4) = "e"
x(5) = "f"
x(6) = "g"
x(7) = "h"
x(8) = "i"
Call a(x(), 6)
End Sub
以下程序用以求数组的交、并、补:
Function n(Array1 As Variant, Array2 As Variant) As Variant()
'交集
Dim ArrayN() As Variant
Dim i As Long, j As Long
Dim count As Long
ReDim ArrayN(IIf(UBound(Array1) > UBound(Array2), UBound(Array1), UBound(Array2)))
For i = 0 To UBound(Array1)
For j = 0 To UBound(Array2)
If Array1(i) = Array2(j) Then
ArrayN(count) = Array1(i)
count = count + 1
Exit For
End If
Next j
Next i
If count > 0 Then
ReDim Preserve ArrayN(count - 1)
n = ArrayN
End If
End Function
Function u(Array1 As Variant, Array2 As Variant) As Variant()
'并集
Dim ArrayU() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
ReDim Preserve ArrayU(UBound(Array1) + UBound(Array2) + 1)
For i = 0 To UBound(Array1)
ArrayU(i) = Array1(i)
Next i
count = UBound(Array1) + 1
For i = 0 To UBound(Array2)
flag = False
For j = 0 To UBound(Array1)
If Array2(i) = Array1(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayU(count) = Array2(i)
count = count + 1
End If
Next i
ReDim Preserve ArrayU(count - 1)
u = ArrayU
End Function
Function s(ArrayAll As Variant, ArraySub As Variant) As Variant()
'补集
Dim ArrayS() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
If UBound(ArrayAll) - UBound(ArraySub) = 0 Then Exit Function
ReDim ArrayS(UBound(ArrayAll) - UBound(ArraySub) - 1)
For i = 0 To UBound(ArrayAll)
flag = False
For j = 0 To UBound(ArraySub)
If ArrayAll(i) = ArraySub(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayS(count) = ArrayAll(i)
count = count + 1
End If
Next i
s = ArrayS
End Function
旋转矩阵原理 :
在数学上一个复式投注单假设有n个三选,m个双选,其中n+m<=13,所有的投注单构成了一个集合C(n,m),C(n,m)共有3的n次方乘以2的m次方个元素,每一个元素可以表示成一个13位长的三重码,在组合数学中已经证明存在至少一个C(n,m)的子集K(n,m),每一个C(n,m)中的元素,都存在一个K(n,m)中的元素,他们之间仅有1位的差别,即所谓的汉明距离(Hamming Distance)等于1。满足上述条件的最小子集K(n,m)称为问题的一个最优解
这是足彩的缩水原理
#12
同楼上
#13
up
#14
一个算法
#15
得有不产生重复的数字
#16
高高!...............
#17
真是高手。。看不明白!。。。
#18
定义一个13*3的数组,然后在数组里面玩.
#19
高手呀!佩服!佩服呀!
#20
谢谢你,川川老师
#21
#1
关注
#2
用数组,至于几维数组,要看你是多少选多少。
删掉不可能得大奖的可能,这个条件要自己设。
删掉不可能得大奖的可能,这个条件要自己设。
#3
定义一个13*3的数组,然后在数组里面玩.
#4
最好是在算法上用多线程,还有就是在数组的设计上不一定就是用13*3的,可以用别的思路
比如做出一个3维的数组
比如做出一个3维的数组
#5
我觉得最好是用数据库来实现
这样可以保留一些历史数据
并且从历史数据里面找出一些规律来
这样可以保留一些历史数据
并且从历史数据里面找出一些规律来
#6
可以用一些条件过滤,参考一些现成的软件
#7
我个人觉得,直接用随机数字分析,旋转矩阵原理过滤,缩水.这是经过科学证明的
#8
我自己的设想是通过数据库来处理,但难道需要我生成190多万中可能吗,那样,我的数据库太过于庞大,如果用数组,用3*13的二维数组里利用条件过滤,怎样对数组进行排除?
#9
随机产生若干不重复的数:
Public Static Sub rand()
Dim count As Integer
Dim intNum As Integer
Dim num As Integer
num = 30’所要的最大数字
For k = 1 To 7‘要的随机数的个数
count = count + 1
Randomize
intNum = Int((num * Rnd) + 1)
If count <> 1 Then
For i = 1 To count - 1
Do Until arrnum(i) <> intNum
If arrnum(i) = intNum Then
intNum = Int((num * Rnd) + 1)
i = 1
End If
Loop
Next i
End If
arrnum(k) = intNum
If count = 7 Then
count = 0
Exit Sub
End If
Next k
End Sub
Public Static Sub rand()
Dim count As Integer
Dim intNum As Integer
Dim num As Integer
num = 30’所要的最大数字
For k = 1 To 7‘要的随机数的个数
count = count + 1
Randomize
intNum = Int((num * Rnd) + 1)
If count <> 1 Then
For i = 1 To count - 1
Do Until arrnum(i) <> intNum
If arrnum(i) = intNum Then
intNum = Int((num * Rnd) + 1)
i = 1
End If
Loop
Next i
End If
arrnum(k) = intNum
If count = 7 Then
count = 0
Exit Sub
End If
Next k
End Sub
#10
三种常用的排序方法:
Sub BubbleSortNumbers(iArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lTemp As Long
For lLoop1 = UBound(iArray) To LBound(iArray) Step -1
For lLoop2 = LBound(iArray) + 1 To lLoop1
If iArray(lLoop2 - 1) > iArray(lLoop2) Then
lTemp = iArray(lLoop2 - 1)
iArray(lLoop2 - 1) = iArray(lLoop2)
iArray(lLoop2) = lTemp
End If
Next lLoop2
Next lLoop1
End Sub
Sub SelectionSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lMin As Long
Dim lTemp As Long
For lLoop1 = LBound(vArray) To UBound(vArray) - 1
lMin = lLoop1
For lLoop2 = lLoop1 + 1 To UBound(vArray)
If vArray(lLoop2) < vArray(lMin) Then lMin = lLoop2
Next lLoop2
lTemp = vArray(lMin)
vArray(lMin) = vArray(lLoop1)
vArray(lLoop1) = lTemp
Next lLoop1
End Sub
Sub ShellSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lHold As Long
Dim lHValue As Long
Dim lTemp As Long
lHValue = LBound(vArray)
Do
lHValue = 3 * lHValue + 1
Loop Until lHValue > UBound(vArray)
Do
lHValue = lHValue / 3
For lLoop1 = lHValue + LBound(vArray) To UBound(vArray)
lTemp = vArray(lLoop1)
lHold = lLoop1
Do While vArray(lHold - lHValue) > lTemp
vArray(lHold) = vArray(lHold - lHValue)
lHold = lHold - lHValue
If lHold < lHValue Then Exit Do
Loop
vArray(lHold) = lTemp
Next lLoop1
Loop Until lHValue = LBound(vArray)
End Sub
Sub BubbleSortNumbers(iArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lTemp As Long
For lLoop1 = UBound(iArray) To LBound(iArray) Step -1
For lLoop2 = LBound(iArray) + 1 To lLoop1
If iArray(lLoop2 - 1) > iArray(lLoop2) Then
lTemp = iArray(lLoop2 - 1)
iArray(lLoop2 - 1) = iArray(lLoop2)
iArray(lLoop2) = lTemp
End If
Next lLoop2
Next lLoop1
End Sub
Sub SelectionSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lMin As Long
Dim lTemp As Long
For lLoop1 = LBound(vArray) To UBound(vArray) - 1
lMin = lLoop1
For lLoop2 = lLoop1 + 1 To UBound(vArray)
If vArray(lLoop2) < vArray(lMin) Then lMin = lLoop2
Next lLoop2
lTemp = vArray(lMin)
vArray(lMin) = vArray(lLoop1)
vArray(lLoop1) = lTemp
Next lLoop1
End Sub
Sub ShellSortNumbers(vArray As Variant)
Dim lLoop1 As Long
Dim lHold As Long
Dim lHValue As Long
Dim lTemp As Long
lHValue = LBound(vArray)
Do
lHValue = 3 * lHValue + 1
Loop Until lHValue > UBound(vArray)
Do
lHValue = lHValue / 3
For lLoop1 = lHValue + LBound(vArray) To UBound(vArray)
lTemp = vArray(lLoop1)
lHold = lLoop1
Do While vArray(lHold - lHValue) > lTemp
vArray(lHold) = vArray(lHold - lHValue)
lHold = lHold - lHValue
If lHold < lHValue Then Exit Do
Loop
vArray(lHold) = lTemp
Next lLoop1
Loop Until lHValue = LBound(vArray)
End Sub
#11
分解成小组合:
Sub a(ByRef theArray() As String, ByVal num As Long)
Dim pos() As Long
Dim i As Long
Dim tmp As String
If num = 0 Then Exit Sub
If num > UBound(theArray) Then num = UBound(theArray)
ReDim pos(num - 1)
For i = 0 To num - 1
pos(i) = i
Next i
Do
tmp = ""
For i = 0 To num - 1
tmp = tmp & theArray(pos(i))
Next i
Print tmp
Loop While Not (b(pos(), num - 1, UBound(theArray)) < 0)
End Sub
Function b(ByRef thePosArray() As Long, ByVal currentPos As Long, ByVal max As Long) As Long
Dim i As Long
b = currentPos
If currentPos < 0 Then Exit Function
thePosArray(currentPos) = thePosArray(currentPos) + 1
For i = currentPos + 1 To UBound(thePosArray)
thePosArray(i) = thePosArray(i - 1) + 1
Next i
If thePosArray(UBound(thePosArray)) > max Then
b = b(thePosArray, currentPos - 1, max)
End If
End Function
Private Sub Command1_Click()
Dim x(8) As String
Dim xx
Cls
x(0) = "a"
x(1) = "b"
x(2) = "c"
x(3) = "d"
x(4) = "e"
x(5) = "f"
x(6) = "g"
x(7) = "h"
x(8) = "i"
Call a(x(), 6)
End Sub
以下程序用以求数组的交、并、补:
Function n(Array1 As Variant, Array2 As Variant) As Variant()
'交集
Dim ArrayN() As Variant
Dim i As Long, j As Long
Dim count As Long
ReDim ArrayN(IIf(UBound(Array1) > UBound(Array2), UBound(Array1), UBound(Array2)))
For i = 0 To UBound(Array1)
For j = 0 To UBound(Array2)
If Array1(i) = Array2(j) Then
ArrayN(count) = Array1(i)
count = count + 1
Exit For
End If
Next j
Next i
If count > 0 Then
ReDim Preserve ArrayN(count - 1)
n = ArrayN
End If
End Function
Function u(Array1 As Variant, Array2 As Variant) As Variant()
'并集
Dim ArrayU() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
ReDim Preserve ArrayU(UBound(Array1) + UBound(Array2) + 1)
For i = 0 To UBound(Array1)
ArrayU(i) = Array1(i)
Next i
count = UBound(Array1) + 1
For i = 0 To UBound(Array2)
flag = False
For j = 0 To UBound(Array1)
If Array2(i) = Array1(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayU(count) = Array2(i)
count = count + 1
End If
Next i
ReDim Preserve ArrayU(count - 1)
u = ArrayU
End Function
Function s(ArrayAll As Variant, ArraySub As Variant) As Variant()
'补集
Dim ArrayS() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
If UBound(ArrayAll) - UBound(ArraySub) = 0 Then Exit Function
ReDim ArrayS(UBound(ArrayAll) - UBound(ArraySub) - 1)
For i = 0 To UBound(ArrayAll)
flag = False
For j = 0 To UBound(ArraySub)
If ArrayAll(i) = ArraySub(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayS(count) = ArrayAll(i)
count = count + 1
End If
Next i
s = ArrayS
End Function
旋转矩阵原理 :
在数学上一个复式投注单假设有n个三选,m个双选,其中n+m<=13,所有的投注单构成了一个集合C(n,m),C(n,m)共有3的n次方乘以2的m次方个元素,每一个元素可以表示成一个13位长的三重码,在组合数学中已经证明存在至少一个C(n,m)的子集K(n,m),每一个C(n,m)中的元素,都存在一个K(n,m)中的元素,他们之间仅有1位的差别,即所谓的汉明距离(Hamming Distance)等于1。满足上述条件的最小子集K(n,m)称为问题的一个最优解
这是足彩的缩水原理
Sub a(ByRef theArray() As String, ByVal num As Long)
Dim pos() As Long
Dim i As Long
Dim tmp As String
If num = 0 Then Exit Sub
If num > UBound(theArray) Then num = UBound(theArray)
ReDim pos(num - 1)
For i = 0 To num - 1
pos(i) = i
Next i
Do
tmp = ""
For i = 0 To num - 1
tmp = tmp & theArray(pos(i))
Next i
Print tmp
Loop While Not (b(pos(), num - 1, UBound(theArray)) < 0)
End Sub
Function b(ByRef thePosArray() As Long, ByVal currentPos As Long, ByVal max As Long) As Long
Dim i As Long
b = currentPos
If currentPos < 0 Then Exit Function
thePosArray(currentPos) = thePosArray(currentPos) + 1
For i = currentPos + 1 To UBound(thePosArray)
thePosArray(i) = thePosArray(i - 1) + 1
Next i
If thePosArray(UBound(thePosArray)) > max Then
b = b(thePosArray, currentPos - 1, max)
End If
End Function
Private Sub Command1_Click()
Dim x(8) As String
Dim xx
Cls
x(0) = "a"
x(1) = "b"
x(2) = "c"
x(3) = "d"
x(4) = "e"
x(5) = "f"
x(6) = "g"
x(7) = "h"
x(8) = "i"
Call a(x(), 6)
End Sub
以下程序用以求数组的交、并、补:
Function n(Array1 As Variant, Array2 As Variant) As Variant()
'交集
Dim ArrayN() As Variant
Dim i As Long, j As Long
Dim count As Long
ReDim ArrayN(IIf(UBound(Array1) > UBound(Array2), UBound(Array1), UBound(Array2)))
For i = 0 To UBound(Array1)
For j = 0 To UBound(Array2)
If Array1(i) = Array2(j) Then
ArrayN(count) = Array1(i)
count = count + 1
Exit For
End If
Next j
Next i
If count > 0 Then
ReDim Preserve ArrayN(count - 1)
n = ArrayN
End If
End Function
Function u(Array1 As Variant, Array2 As Variant) As Variant()
'并集
Dim ArrayU() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
ReDim Preserve ArrayU(UBound(Array1) + UBound(Array2) + 1)
For i = 0 To UBound(Array1)
ArrayU(i) = Array1(i)
Next i
count = UBound(Array1) + 1
For i = 0 To UBound(Array2)
flag = False
For j = 0 To UBound(Array1)
If Array2(i) = Array1(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayU(count) = Array2(i)
count = count + 1
End If
Next i
ReDim Preserve ArrayU(count - 1)
u = ArrayU
End Function
Function s(ArrayAll As Variant, ArraySub As Variant) As Variant()
'补集
Dim ArrayS() As Variant
Dim i As Long, j As Long
Dim count As Long
Dim flag As Boolean
If UBound(ArrayAll) - UBound(ArraySub) = 0 Then Exit Function
ReDim ArrayS(UBound(ArrayAll) - UBound(ArraySub) - 1)
For i = 0 To UBound(ArrayAll)
flag = False
For j = 0 To UBound(ArraySub)
If ArrayAll(i) = ArraySub(j) Then
flag = True
Exit For
End If
Next j
If Not flag Then
ArrayS(count) = ArrayAll(i)
count = count + 1
End If
Next i
s = ArrayS
End Function
旋转矩阵原理 :
在数学上一个复式投注单假设有n个三选,m个双选,其中n+m<=13,所有的投注单构成了一个集合C(n,m),C(n,m)共有3的n次方乘以2的m次方个元素,每一个元素可以表示成一个13位长的三重码,在组合数学中已经证明存在至少一个C(n,m)的子集K(n,m),每一个C(n,m)中的元素,都存在一个K(n,m)中的元素,他们之间仅有1位的差别,即所谓的汉明距离(Hamming Distance)等于1。满足上述条件的最小子集K(n,m)称为问题的一个最优解
这是足彩的缩水原理
#12
同楼上
#13
up
#14
一个算法
#15
得有不产生重复的数字
#16
高高!...............
#17
真是高手。。看不明白!。。。
#18
定义一个13*3的数组,然后在数组里面玩.
#19
高手呀!佩服!佩服呀!
#20
谢谢你,川川老师