RosettaCodeData/Task/Cantor-set/FreeBASIC/cantor-set.basic
2023-07-01 13:44:08 -04:00

36 lines
855 B
Text

Const ancho = 81
Const alto = 5
Dim Shared intervalo(alto, ancho) As String
Dim As Integer i, j
Sub Cantor()
Dim As Integer i, j
For i = 0 To alto - 1
For j = 0 To ancho - 1
intervalo(i, j) = Chr(254)
Next j
Next i
End Sub
Sub ConjCantor(inicio As Integer, longitud As Integer, indice As Integer)
Dim As Integer i, j
Dim segmento As Integer = longitud / 3
If segmento = 0 Then Return
For i = indice To alto - 1
For j = inicio + segmento To inicio + segmento * 2 - 1
intervalo(i, j) = Chr(32)
Next j
Next i
ConjCantor(inicio, segmento, indice + 1)
ConjCantor(inicio + segmento * 2, segmento, indice + 1)
End Sub
Cantor()
ConjCantor(0, ancho, 1)
For i = 0 To alto - 1
For j = 0 To ancho - 1
Print intervalo(i, j);
Next j
Print
Next i
End