|
本帖最后由 一把小刀闯天下 于 2018-9-30 13:43 编辑
'至少25个相同
'如果只有25个相同应该无解,因为至少需要525个数才会有解,除非每组可以有相同的数
Option Explicit
Sub test()
Dim arr, i, j, n, t
ReDim arr(1 To 100)
For i = 1 To 100: arr(i) = i: Next
ReDim brr(1 To 50, 1 To 20)
Randomize
For i = 1 To UBound(arr, 1)
n = Int(Rnd * 100) + 1
t = arr(i): arr(i) = arr(n): arr(n) = t
Next
For i = 1 To 25
For j = 1 To UBound(brr, 2): brr(i, j) = arr(i): Next
Next
For j = 1 To UBound(brr, 2)
For i = 26 To UBound(brr, 1)
n = Int(Rnd * (100 - i + 1)) + i
t = arr(i): arr(i) = arr(n): arr(n) = t
brr(i, j) = arr(i)
Next i, j
For j = 1 To UBound(brr, 2)
For i = 1 To UBound(brr, 1)
n = Int(Rnd * UBound(brr, 1)) + 1
t = brr(i, j): brr(i, j) = brr(n, j): brr(n, j) = t
Next i, j
[a1].Resize(UBound(brr, 1), UBound(brr, 2)) = brr
End Sub
|
|