golang 声明数组
作者:互联网
package main
import "fmt"
func main() {
var arr [4]int
arr1 := [3]int{1, 2, 3}
arr2 := [...]int{5, 6} // 个数不确定
arr3 := [3][5]int{ // 3和5分别代表行,列
{1, 3, 4, 4, 4},
{1, 3, 4, 4, 4},
{1, 3, 4, 4, 4},
}
fmt.Println(arr, arr1, arr2, arr3) // [0 0 0 0] [1 2 3] [5 6] [[1 3 4 4 4] [1 3 4 4 4] [1 3 4 4 4]]
}
标签:arr,arr1,int,fmt,golang,arr3,arr2,数组,声明 来源: https://blog.csdn.net/goddnss/article/details/121012791