Ejercicio
Ordenar datos
Objetivo
Cree un programa de Visual Basic para pedir al usuario 10 números enteros (de -1000 a 1000), ordenarlos y mostrarlos ordenados.
Código
Imports System
Public Class exercise91
Public Shared Sub Main()
Dim total As Integer = 9
Dim data As Integer() = New Integer(total - 1) {}
Dim i, j, aux As Integer
For i = 0 To total - 1
Console.Write("Enter number {0}: ", i + 1)
data(i) = Convert.ToInt32(Console.ReadLine())
Next
For i = 0 To total - 1 - 1
For j = i + 1 To total - 1
If data(i) > data(j) Then
aux = data(i)
data(i) = data(j)
data(j) = aux
End If
Next
Next
Console.Write("Sorted:")
For Each valor As Integer In data
Console.Write("{0} ", valor)
Next
End Sub
End Class