2016-12-05 18:59:57 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
func main() {
|
2018-10-31 08:43:30 +03:00
|
|
|
arr := [9]int{2, 1, 4, 3, 5, 9, 7, 6, 8}
|
2016-12-05 18:59:57 +03:00
|
|
|
|
2018-10-31 08:43:30 +03:00
|
|
|
for out := 1; out < len(arr); out++ {
|
|
|
|
temp := arr[out]
|
2016-12-05 18:59:57 +03:00
|
|
|
in := out
|
|
|
|
|
2018-10-31 08:43:30 +03:00
|
|
|
for ; in > 0 && arr[in-1] >= temp; in-- {
|
2016-12-05 18:59:57 +03:00
|
|
|
arr[in] = arr[in-1]
|
|
|
|
}
|
|
|
|
arr[in] = temp
|
|
|
|
}
|
|
|
|
|
2018-10-31 08:43:30 +03:00
|
|
|
for _, sortedvals := range arr {
|
2016-12-05 18:59:57 +03:00
|
|
|
fmt.Println(sortedvals)
|
|
|
|
}
|
|
|
|
}
|