标签:原因 class pack port ++ UNC ack int 一个
package main import "fmt" func main() { /* 输入:["h","e","l","l","o"] 输出:["o","l","l","e","h"] */ arr := []string{"h", "e", "l", "l", "o"} //需要一个副本的原因是,做位置交换的时候,前面的字母已经被改变了 arr2 := []string{"h", "e", "l", "l", "o"} for i := 0; i < len(arr); i++ { arr2[i] = arr[len(arr)-1-i] } fmt.Println(arr2) }
标签:原因 class pack port ++ UNC ack int 一个
原文地址:https://www.cnblogs.com/yzg-14/p/12386913.html