Created
September 15, 2014 09:30
-
-
Save dlion/7e9c718c1ffa3b8863e4 to your computer and use it in GitHub Desktop.
InsertionSort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
array := [6]int{5, 3, 1, 7, 2} | |
for k := 0; k <= 5; k++ { | |
m := k | |
for j := k + 1; j <= 5; j++ { | |
if array[j] < array[m] { | |
m = j | |
} | |
} | |
temp := array[m] | |
array[m] = array[k] | |
array[k] = temp | |
} | |
for i := 0; i < 6; i++ { | |
fmt.Printf("%d ", array[i]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment