no tiene las comprobaciones de si es Par y mayor a 2 y menor a 180 pero bueno eso ya lo tenemos por sabido.
Código (VB) [Seleccionar]
Private Function Leandro_Cuenta_Circular7913(N&, m() As Integer, TIPO As Boolean)
Dim Max As Long
Dim X1 As Long
Dim X2 As Long
Dim Y1 As Long
Dim Y2 As Long
Dim lCont As Long
Dim I As Long
Dim j As Long
Dim Mitad As Long
Max = N * N
ReDim m(0 To N, 0 To N)
If TIPO Then
X2 = N
Y2 = N
Do While lCont < Max
m(X1, Y1) = 7
X1 = X1 + 1
For I = X1 To N - X1
lCont = lCont + 1
m(I, Y1) = lCont
Next
m(I, Y1) = 9
Y1 = Y1 + 1
For I = Y1 To N - Y1
lCont = lCont + 1
m(X2, I) = lCont
Next
m(X2, I) = 3
X2 = X2 - 1
For I = X2 To X1 Step -1
lCont = lCont + 1
m(I, Y2) = lCont
Next
m(I, Y2) = 1
Y2 = Y2 - 1
For I = Y2 To Y1 Step -1
lCont = lCont + 1
m(X1 - 1, I) = lCont
Next
Loop
Else
Mitad = N / 2
For I = 0 To Mitad - 1
m(X1, I) = 7
X1 = X1 + 1
For j = X1 To N - X1
lCont = lCont + 1
m(j, I) = lCont
Next
m(j, I) = 9
Next
For I = N To Mitad + 1 Step -1
Y1 = Y1 + 1
For j = Y1 To N - Y1
lCont = lCont + 1
m(I, j) = lCont
Next
m(j, I) = 3
Next
For I = N To Mitad + 1 Step -1
Y2 = Y2 + 1
For j = N - Y2 To Y2 Step -1
lCont = lCont + 1
m(j, I) = lCont
Next
m(j, I) = 1
Next
For I = 0 To Mitad - 1
X2 = X2 + 1
For j = N - X2 To X2 Step -1
lCont = lCont + 1
m(I, j) = lCont
Next
Next
End If
End Function
Código (VB) [Seleccionar]
Option Explicit
Private Sub Form_Load()
Dim X As Long, Y As Long
Dim m() As Integer
Dim N As Long
N = 8
Leandro_Cuenta_Circular7913 N, m, False
For Y = 0 To N
For X = 0 To N
Debug.Print m(X, Y),
Next
Debug.Print
Next
Debug.Print vbCrLf
Leandro_Cuenta_Circular7913 N, m, True
For Y = 0 To N
For X = 0 To N
Debug.Print m(X, Y),
Next
Debug.Print
Next
End Sub