代码拉取完成,页面将自动刷新
package main
import (
"fmt"
"sort"
)
func testIntSort() {
var a = [...]int{1, 5, 443, 8, 3, 66, 23, 86}
sort.Ints(a[:])
fmt.Println(a)
}
func testStringSort() {
var a = [...]string{"abc", "efg", "cdf", "c", "ed"}
sort.Strings(a[:])
fmt.Println(a)
}
func testFloat() {
var a = []float64{0.33, 0.25, 0.111, 1.23, 2.32}
sort.Float64s(a[:])
fmt.Println(a)
}
func testSearchInts() {
var a = [...]int{1, 5, 443, 8, 3, 66, 23, 86}
sort.Ints(a[:])
fmt.Println(a)
result := sort.SearchInts(a[:], 21)
fmt.Println(result)
}
func testSearchStrings() { //Search返回的可以插入的位置,
var a = [...]string{"abc", "efg", "cdf", "c", "ed"} //即如果这个值插入的话,放在哪里
sort.Strings(a[:])
fmt.Println(a)
result := sort.SearchStrings(a[:], "df")
fmt.Println(result)
}
func main() {
// testIntSort()
// testStringSort()
// testFloat()
// testSearchInts()
// testSearchStrings()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。