7,763
社区成员
发帖
与我相关
我的任务
分享
Const XX = 9
Const YY = 9
Dim matrix(XX, YY) As Integer
Dim i As Long
Dim x As Long
Dim y As Long
Dim tx As Long
Dim ty As Long
Dim index As Long
index = 1
x = XX - 1
y = (YY + 1) / 2 - 1
For i = 0 To XX * YY
matrix(i / XX, i Mod YY) = 0
Next i
For i = 1 To XX * YY
matrix(x, y) = i
tx = (x + 1) Mod XX
ty = (y + 1) Mod YY
If matrix(tx, ty) <> 0 Then
If x = 0 Then
x = XX
Else
x = x - 1
End If
Else
x = tx
y = ty
End If
Next i
Dim str1 As String
For x = 0 To XX - 1
str1 = ""
For y = 0 To YY - 1
str1 = str1 + Str(matrix(x, y)) + " "
Next y
Debug.Print str1
Next x