Non-continuous subsequences: Difference between revisions
Content added Content deleted
m (added related tasks.) |
(Non-continuous subsequences en FreeBASIC) |
||
Line 984: | Line 984: | ||
===Conclusion=== |
===Conclusion=== |
||
Find a better filter or use the generator. |
Find a better filter or use the generator. |
||
=={{header|FreeBASIC}}== |
|||
{{trans|BBC BASIC}} |
|||
<lang freebasic>Sub Subsecuencias_no_continuas(l() As String) |
|||
Dim As Integer i, j, g, n, r, s, w |
|||
Dim As String a, b, c |
|||
n = Ubound(l) |
|||
For s = 0 To n-2 |
|||
For g = s+1 To n-1 |
|||
a = "[" |
|||
For i = s To g-1 |
|||
a += l(i) + ", " |
|||
Next i |
|||
For w = 1 To n-g |
|||
r = n+1-g-w |
|||
For i = 1 To 2^r-1 Step 2 |
|||
b = a |
|||
For j = 0 To r-1 |
|||
If i And 2^j Then b += l(g+w+j) + ", " |
|||
Next j |
|||
'Print Left(Left(b)) + "]" |
|||
c = (Left(b, Len (b)-1)) |
|||
Print Left(c, Len(c)-1) + "]" |
|||
Next i |
|||
Next w |
|||
Next g |
|||
Next s |
|||
End Sub |
|||
Dim lista1(3) As String = {"1", "2", "3", "4"} |
|||
Print "Para [1, 2, 3, 4] las subsecuencias no continuas son:" |
|||
Subsecuencias_no_continuas(lista1()) |
|||
Dim lista2(4) As String = {"e", "r", "n", "i", "t"} |
|||
Print "Para [e, r, n, i, t] las subsecuencias no continuas son:" |
|||
Subsecuencias_no_continuas(lista2()) |
|||
Sleep</lang> |
|||
{{out}} |
|||
<pre> |
|||
Para [1, 2, 3, 4] las subsecuencias no continuas son: |
|||
[1, 3] |
|||
[1, 3, 4] |
|||
[1, 4] |
|||
[1, 2, 4] |
|||
[2, 4] |
|||
Para [e, r, n, i, t] las subsecuencias no continuas son: |
|||
[e, n] |
|||
[e, n, i] |
|||
[e, n, t] |
|||
[e, n, i, t] |
|||
[e, i] |
|||
[e, i, t] |
|||
[e, t] |
|||
[e, r, i] |
|||
[e, r, i, t] |
|||
[e, r, t] |
|||
[e, r, n, t] |
|||
[r, i] |
|||
[r, i, t] |
|||
[r, t] |
|||
[r, n, t] |
|||
[n, t] |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |