You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

24 lines
429 B

fn main() {
let arr = [2, 5, 3, 1, 4]
let n = len(arr)
let c = 0
while c < n {
let d = 0
while d < n - c - 1 {
let current = arr[d]
let next = arr[d+1]
if current > next {
let swap = arr[d]
arr[d] = arr[d+1]
arr[d+1] = swap
}
d += 1
}
c += 1
}
println(arr)
}