|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
偶在琢磨动态规划,各个段该怎么划定范围,怎么计算!!
版版们在用递归
偶想,有一点是应该先做的
Sub 去除不通的路()
Dim z%, x%, y%
For z = 1 To 2
For x = 31 To 2 Step -1
For y = 30 To 2 Step -1
If Cells(x, y) <> "" Then
If Cells(x, y - 1) = "" And Cells(x + 1, y) = "" And Cells(x, y + 1) = "" Then Cells(x, y) = ""
If Cells(x + 1, y) = "" And Cells(x, y + 1) = "" And Cells(x - 1, y) = "" Then Cells(x, y) = ""
End If
Next y
Next x
For x = 2 To 31
For y = 2 To 30
If Cells(x, y) <> "" Then
If Cells(x + 1, y) = "" And Cells(x, y - 1) = "" And Cells(x - 1, y) = "" Then Cells(x, y) = ""
If Cells(x, y - 1) = "" And Cells(x - 1, y) = "" And Cells(x, y + 1) = "" Then Cells(x, y) = ""
End If
Next y
Next x
Next z
End Sub |
|