1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package main
import "fmt"
func main() {
// 先声明三维数组
var arr [2][3][4]int
// 后赋值
arr[0][0] = [4]int{1,2,3,4}
arr[0][1] = [4]int{10,20,30,40}
arr[0][2] = [4]int{100,200,300,400}
arr[1][0] = [4]int{11,22,33,44}
arr[1][1] = [4]int{111,222,333,333}
arr[1][2] = [4]int{1111,2222,3333,4444}
fmt.Printf("arr类型: %T 值: %v \n",arr,arr)
// 直接声明三维数组
arr2 := [2][3][4]int {
{
{1,2,3,4},
{10,20,30,40},
{100,200,300,400},
},
{
{11,22,33,44},
{111,222,333,333},
{1111,2222,3333,4444},
},
}
fmt.Printf("arr2类型: %T 值: %v",arr2,arr2)
}
/**输出
arr类型: [2][3][4]int 值: [[[1 2 3 4] [10 20 30 40] [100 200 300 400]] [[11 22 33 44] [111 222 333 333] [1111 2222 3333 4444]]]
arr2类型: [2][3][4]int 值: [[[1 2 3 4] [10 20 30 40] [100 200 300 400]] [[11 22 33 44] [111 222 333 333] [1111 2222 3333 4444]]]
*/
|