1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Sub Main()
Dim tab() As Integer
Dim i, j, min, nbre, temp As Integer
Console.WriteLine("Donner la valeur du tab")
nbre = Console.ReadLine
ReDim tab(nbre)
For i = 0 To nbre - 1
Console.WriteLine("Donner la val de la case" & (i + 1) & ":")
tab(nbre) = Console.ReadLine
Next
min = 0
For i = 0 To nbre - 1
If tab(i) > tab(i + 1) Then
min = i
End If
For j = i + 1 To nbre - 1 Step -1
temp = tab(min)
tab(j - 1) = tab(j)
Next j
Next i
Console.WriteLine(tab(nbre))
Console.ReadKey()
End Sub |
Partager