|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
'过河方案brr() 有49种,对应返回方案也是49种。
Sub 按钮1_Click()
m = 3
n = 3
k0 = (m + 1) * (n + 1)
Dim arr()
ReDim arr(1 To k0, 1 To 2)
For i = 0 To m
For j = 0 To n
k = k + 1
arr(k, 1) = i
arr(k, 2) = j
Next
Next
Dim brr()
ReDim brr(1 To 999, 1 To 1)
For i = 1 To k0 - 1
For j = i + 1 To k0
x1 = arr(j, 1) - arr(i, 1)
x2 = arr(j, 2) - arr(i, 2)
If x2 >= 0 And x1 <= 2 - x2 Then
k1 = k1 + 1
brr(k1, 1) = arr(i, 1) & arr(i, 2) & "++" & arr(j, 1) & arr(j, 2)
End If
Next
Next
[a1].Resize(999, 1) = brr
End Sub |
|