package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
|
|
numbers := []int{5, 8, 2, 4, 0, 1, 3, 7, 9, 6}
|
|
|
|
fmt.Println("Before:", numbers)
|
|
|
|
for swapped := true; swapped == true; {
|
|
swapped = false
|
|
for i := 1; i < len(numbers); i++ {
|
|
if numbers[i] < numbers[i-1] {
|
|
numbers[i-1], numbers[i] = numbers[i], numbers[i-1]
|
|
swapped = true
|
|
}
|
|
}
|
|
}
|
|
|
|
fmt.Println("After: ", numbers)
|
|
|
|
}
|