Go语言 之数组倒序
package main import ( "fmt" ) //数组倒序函数 func Reverse(arr *[3]string, length int) { var temp string for i := 0; i < length/2; i++ { temp = (*arr)[i] (*arr)[i] = (*arr)[length-1-i] (*arr)[length-1-i] = temp } } func main() { s := [3]string{"a", "b", "c"} Reverse(&s, 3) fmt.Println(s) }