No lei bien... Sorry...
DoEvents!
DoEvents!
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
Option Explicit
Option Base 0
Private Static Function MrFrog_ZigZag(ByVal dSize#, ByRef dMatrix#()) As Boolean
Dim bMiddle As Boolean
Dim lMax&, lRealMax&, dNum#, dDec#
Dim x&, y&, w&, n&, q&
If Not (dSize# And &H80000000) Then
dDec# = dSize# - VBA.Int(dSize#)
lMax& = VBA.Int(Math.Sqr(dSize#))
lRealMax& = lMax& + &H1
ReDim dMatrix#(lRealMax&, lRealMax&)
If dSize# = &H0 Then GoTo True_
dMatrix#(&H1, &H0) = &H1 + dDec#
x& = &H1: y& = &H1
n& = &H2: w& = &H2
Do
Do While ((y& > -&H1) And (x& < lRealMax&))
dMatrix#(x&, y&) = n& + dDec#
x& = x& + &H1: y& = y& - &H1
n& = n& + &H1
Loop
If n& > dSize# Then Exit Do
If w& = lMax& Then
w& = &H1
bMiddle = True
End If
w& = w& + &H1
If bMiddle Then
x& = w&
y& = lMax& - &H1
Else
y& = y& + w&
x& = &H1
End If
Loop
For y& = &H0 To lMax&
q& = y& + &H1
For x& = &H1 To lMax&
dMatrix#(lRealMax&, y&) = ((dMatrix#(lRealMax&, y&)) + (dMatrix#(x&, y&)))
dMatrix#(q&, lMax&) = ((dMatrix#(q&, lMax&)) + (dMatrix#(q&, x& - &H1)))
Next x&
Next y&
dNum# = dMatrix#(lRealMax&, lMax&)
dMatrix#(lRealMax&, lMax&) = (dMatrix#(lRealMax&, lMax&) / &H2)
dMatrix#(&H0&, lMax&) = dMatrix#(lRealMax&, lMax&)
lMax& = lMax& - &H1
For y& = &H0 To lMax&
dMatrix#(&H0, y&) = (dMatrix#(lRealMax&, y&)) + dNum#
Next y&
True_:
MrFrog_ZigZag = &H1
End If
End Function
Private Sub Form_Load()
Dim a() As Double
If MrFrog_ZigZag(9.233, a) Then
PrintMatrix a
End If
End Sub
Private Sub PrintMatrix(ByRef sMatrix() As Double)
Dim b As Long
Dim q As Long
Dim s As String
Const sLine As String = "-----------------------"
Debug.Print
Debug.Print sLine; Time$; sLine
For b = 0 To UBound(sMatrix)
For q = 0 To UBound(sMatrix) - 1
s = s & sMatrix(b, q) & String$(3, vbTab)
Next
Debug.Print s
s = vbNullString
Next
Debug.Print
End Sub
-----------------------02:58:37-----------------------
104,893 109,893 114,893 47,097
1,233 2,233 4,233 7,699
3,233 5,233 7,233 15,699
6,233 8,233 9,233 23,699
10,699 15,699 20,699 47,097
-----------------------09:19:37-----------------------
10320 10374 10435 10501 10570 10640 10709 10775 10836 10890 5050
1 2 4 7 11 16 22 29 37 46 175
3 5 8 12 17 23 30 38 47 56 239
6 9 13 18 24 31 39 48 57 65 310
10 14 19 25 32 40 49 58 66 73 386
15 20 26 33 41 50 59 67 74 80 465
21 27 34 42 51 60 68 75 81 86 545
28 35 43 52 61 69 76 82 87 91 624
36 44 53 62 70 77 83 88 92 95 700
45 54 63 71 78 84 89 93 96 98 771
55 64 72 79 85 90 94 97 99 100 835
220 274 335 401 470 540 609 675 736 790 5050
VariableString = VariableString & "[back]"
VariableString = Left$(VariableString, Len(VariableString) - 1)