fmt.Println("The square of the first box is", square)
}
谁能告诉我正确的平方方法?问题是无效直接的 square(type[4]int)
翻过高山走不出你
浏览 189回答 1
1回答
小唯快跑啊
你可能想要这样的东西:package mainimport ( "fmt")func main() { box := []int{1, -2, 3, 4} square := make([]int, len(box)) for i, v := range box { square[i] = v*v } fmt.Println("The square of the first box is ", square)}