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 35
| Function BubbleSort(arrInt)
for i = UBound(arrInt) - 1 To 0 Step -1
for j= 0 to i
if arrInt(j)>arrInt(j+1) then
temp = arrInt(j+1)
arrInt(j+1) = arrInt(j)
arrInt(j) = temp
end if
next
next
BubbleSort = arrInt
End Function
Dim arrValue
arrValue = Array(12,24,51,24,15,35,1000,15,65,418,0,-5,842,-540,-65,75)
MsgBox Join(BubbleSort(arrValue),","),64,"Tri à bulle"
Dim iLen
Dim aChars()
Dim inputString : inputString = "poiuytrezamlkjhgfdsqnbvcxw"
iLen = Len(inputString)-1
ReDim aChars(iLen)
For i = 0 to iLen
aChars(i) = Mid(inputString, i + 1,1)
Next
MsgBox Join(BubbleSort(aChars),","),64,"Tri à bulle"
inputstring = "Bonjour"
iLen = Len(inputString)-1
ReDim aChars(iLen)
For i = 0 to iLen
aChars(i) = Mid(inputString, i + 1,1)
Next
MsgBox Join(BubbleSort(aChars),""),64,"Tri à bulle" |
Partager