Skip to content

Instantly share code, notes, and snippets.

@178inaba
Last active August 29, 2015 14:19
Show Gist options
  • Save 178inaba/32476ff81b6fd159b367 to your computer and use it in GitHub Desktop.
Save 178inaba/32476ff81b6fd159b367 to your computer and use it in GitHub Desktop.
sort.SearchInts()はSort済みじゃないと動かない ref: http://qiita.com/inaba178/items/795c2e18078c4063a264
package main
import (
"fmt"
"sort"
)
func main() {
a := []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
res := sort.SearchInts(a, 7)
fmt.Println("array:", a)
fmt.Println("result:", res)
}
package main
import (
"fmt"
"sort"
)
func main() {
a := []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
sort.Ints(a)
res := sort.SearchInts(a, 7)
fmt.Println("array:", a)
fmt.Println("result:", res)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment