June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,22 +1,11 @@
function bubblesort!{T}(x::AbstractArray{T})
for i in 2:length(x)
for j in 1:length(x)-1
if x[j] > x[j+1]
tmp = x[j]
x[j] = x[j+1]
x[j+1] = tmp
end
function bubblesort!(arr::AbstractVector)
for _ in 2:length(arr), j in 1:length(arr)-1
if arr[j] > arr[j+1]
arr[j], arr[j+1] = arr[j+1], arr[j]
end
end
end
return x
return arr
end
a = [rand(-100:100) for i in 1:20]
println("Before bubblesort:")
println(a)
a = bubblesort!(a)
println("\nAfter bubblesort:")
println(a)
v = rand(-10:10, 10)
println("# unordered: $v\n -> ordered: ", bubblesort!(v))