Que es el Ordenamiento_de_burbuja?
' gambas class file
'by postapase
Public num As Integer
Public numeritos As String
Public Sub Form_Open()
Me.Center
End
Public Sub Button1_Click()
Dim arrayNum As Integer[] = ["55", "86", "48", "16", "82"]
Dim x, y, a, s, Rota1, Rota2 As Integer
TextArea1.Clear
Repeat
If a = 4 Then a = 0
If y = 4 Then y = 0
If arrayNum[y] < arrayNum[a + 1] Then
Inc y
Inc a
Inc s
Continue
Endif
Rota1 = 0
Rota2 = 0
Rota1 = arrayNum[y]
Rota2 = arrayNum[a + 1]
arrayNum[y] = Rota2
arrayNum[a + 1] = Rota1
Dec s
For Each num In arrayNum
numeritos &= num & " "
Wait 0.2
Next
TextArea1.Text &= numeritos & gb.NewLine
numeritos = ""
Until s > 4
For Each num In arrayNum
numeritos &= num & " "
Wait 0.2
Next
TextArea1.Text &= gb.NewLine & "Resultado final es: " & numeritos & gb.NewLine
End
' gambas class file
'by postapase
Public num As Integer
Public numeritos As String
Public Sub Form_Open()
Me.Center
End
Public Sub Button1_Click()
Dim arrayNum As Integer[] = ["55", "86", "48", "16", "82"]
Dim x, y, a, s, Rota1, Rota2 As Integer
TextArea1.Clear
Repeat
If a = 4 Then a = 0
If y = 4 Then y = 0
If arrayNum[y] < arrayNum[a + 1] Then
Inc y
Inc a
Inc s
Continue
Endif
Rota1 = 0
Rota2 = 0
Rota1 = arrayNum[y]
Rota2 = arrayNum[a + 1]
arrayNum[y] = Rota2
arrayNum[a + 1] = Rota1
Dec s
For Each num In arrayNum
numeritos &= num & " "
Wait 0.2
Next
TextArea1.Text &= numeritos & gb.NewLine
numeritos = ""
Until s > 4
For Each num In arrayNum
numeritos &= num & " "
Wait 0.2
Next
TextArea1.Text &= gb.NewLine & "Resultado final es: " & numeritos & gb.NewLine
End
Código fuente: OrdenandoNumeros
Muy interesante, no sabía que existían esos controladores de flujo............... siempre se aprende algo nuevo. Gracias.
ResponderBorrar