Sorting algorithms/Insertion sort: Difference between revisions
Content deleted Content added
Drkameleon (talk | contribs) |
Sorting algorithms/Insertion sort en Yabasic |
||
Line 4,127:
-5 1 1 2 3 4 4 5 6 9
</pre>
=={{header|Yabasic}}==
{{trans|FreeBASIC}}
<lang yabasic>
sub InsertionSort (matriz())
for i = 1 to arraysize(matriz(),1)
valor = matriz(i)
j = i - 1
while (j >= 0) and (valor < matriz(j))
matriz(j + 1) = matriz(j)
j = j - 1
wend
matriz(j + 1) = valor
next i
end sub
//--------------------------
dim array(10)
print "Antes de ordenar:"
for i = 1 to 10
array(i) = int(ran(32768))
print array(i), " ";
next i
print
print "\nDespues de ordenar:"
InsertionSort(array())
for i = 1 to 10
print array(i), " ";
next i
print
end
</lang>
=={{header|Yorick}}==
|