Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,25 @@
function bubblesort{T}(a::AbstractArray{T,1})
b = copy(a)
isordered = false
span = length(b)
while !isordered && span > 1
isordered = true
for i in 2:span
if b[i] < b[i-1]
t = b[i]
b[i] = b[i-1]
b[i-1] = t
isordered = false
end
end
span -= 1
end
return b
end
a = [rand(-100:100) for i in 1:20]
println("Before bubblesort:")
println(a)
a = bubblesort(a)
println("\nAfter bubblesort:")
println(a)