package main
import "fmt"
func main() {
people := [][2]int{
{7, 0}, {4, 4}, {27, 1}, {5, 0}, {6, 1}, {5, 2},
}
//把{27, 1}插到第一个位置
p := people[2] // 先复制一份
copy(people[1:3], people[0:3])
people[0] = p
fmt.Println(people)
//把{27, 1}复制到最后一个位置,第一个位置同理
//p := people[2]
//copy(people[2:], people[3:])
//people[len(people)-1] = p
//fmt.Println(people)
}
|
请发表评论