March 2019
Intermediate to advanced
336 pages
9h 9m
English
An array is a homogeneous collection of data elements. An array's indexes range from index 0 to index m-1, where m is the fixed length of the array. An array with multiple dimensions is an array of an array. The following code initializes a multi-dimensional array. A three-dimensional array is printed:
///main package has examples shown// in Go Data Structures and algorithms bookpackage main// importing fmt packageimport ( "fmt" "math/rand")//main methodfunc main() {var threedarray [2][2][2]intvar i intvar j intvar k intfor i=0; i < 2; i++ { for j=0; j < 2; j++ { for k=0; k < 2; k++ { threedarray[i][j][k] = rand.Intn(3) } }} fmt.Println(threedarray)}
Run the following command to execute the preceding code snippet: ...
Read now
Unlock full access