package main
import (
"fmt"
"sort"
)
func in(target string, str_array []string) bool {
sort.Strings(str_array)
index := sort.SearchStrings(str_array, target)
if index < len(str_array) && str_array[index] == target {
return true
}
return false
}
func main(){
name_list := []string{"pm", "kingname", "青南"}
target1 := "kingname"
target2 := "产品经理"
result := in(target1, name_list)
fmt.Println("kingname 是否在 name_list 中:", result)
result = in(target2, name_list)
fmt.Println("产品经理是否在 name_list 中:", result)
}