Skip to content

Commit

Permalink
fix insertion sort error and reformat file
Browse files Browse the repository at this point in the history
  • Loading branch information
zyt312074545 committed Oct 31, 2018
1 parent c976db1 commit 3bcfa10
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sorts/insertion_sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package main
import "fmt"

func main() {
arr:= [9]int{2,1,4,3,5,9,7,6,8}
arr := [9]int{2, 1, 4, 3, 5, 9, 7, 6, 8}

for out:=1; out<len(arr); out++{
temp:=arr[out]
for out := 1; out < len(arr); out++ {
temp := arr[out]
in := out

for;in>0 && arr[in-1]>=temp;in--{
for ; in > 0 && arr[in-1] >= temp; in-- {
arr[in] = arr[in-1]
}
arr[in] = temp
}

for sortedvals:= range arr{
for _, sortedvals := range arr {
fmt.Println(sortedvals)
}
}

0 comments on commit 3bcfa10

Please sign in to comment.