Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Power-set/FreeBASIC/power-set.basic
Normal file
26
Task/Power-set/FreeBASIC/power-set.basic
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Function ConjuntoPotencia(set() As String) As String
|
||||
If Ubound(set,1) > 31 Then Print "Set demasiado grande para representarlo como un entero" : Exit Function
|
||||
If Ubound(set,1) < 0 Then Print "{}": Exit Function ' Set vacío
|
||||
Dim As Integer i, j
|
||||
Dim As String s = "{"
|
||||
For i = Lbound(set) To (2 Shl Ubound(set,1)) - 1
|
||||
s += "{"
|
||||
For j = Lbound(set) To Ubound(set,1)
|
||||
If i And (1 Shl j) Then s += set(j) + ","
|
||||
Next j
|
||||
If Right(s,1) = "," Then s = Left(s,Len(s)-1)
|
||||
s += "},"
|
||||
Next i
|
||||
Return Left(s,Len(s)-1) + "}"
|
||||
End Function
|
||||
|
||||
Print "El power set de [1, 2, 3, 4] comprende:"
|
||||
Dim As String set(3) = {"1", "2", "3", "4"}
|
||||
Print ConjuntoPotencia(set())
|
||||
Print !"\nEl power set de [] comprende:"
|
||||
Dim As String set0()
|
||||
Print ConjuntoPotencia(set0())
|
||||
Print "El power set de [[]] comprende:"
|
||||
Dim As String set1(0) = {""}
|
||||
Print ConjuntoPotencia(set1())
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue