1// Two dimensional array
2int a[2][3]= {
3 {1, 2, 3},
4 {4, 5, 6}
5 };
6
7 cout << a[1][1]; // Output is 5
8
9// Three dimensional array
10//[2] is elements; [3] is rows in elements; [4] is column in elemnents
11int a[2][3][2]= {
12 //Element 0
13 { {1, 2},
14 {2, 3},
15 {4, 5}
16
17 },
18
19
20 // Element 1
21 { {6, 7},
22 {8, 9},
23 {10, 11}
24
25 }
26 };
27
28 cout << a[0][1][1]; // Prints 3
29
1void printMatrix(array<array<int, COLS>, ROWS> matrix){
2for (auto row : matrix){
3//auto infers that row is of type array<int, COLS>
4for (auto element : row){
5cout << element << ' ';
6}
7cout << endl;
8}
1 int MyArray[2][3] = { {2, 3, 4}, {12, 13, 14} };
2
3 //visualize
4 //2, 3, 4
5 //12, 13, 14
6
7 std::cout << MyArray[0][2] << endl; // 4
8 std::cout << MyArray[1][1] << endl; // 13
9
10//First square bracket means how many rows you want in your array
11//Second squire bracket is for how many qulam you want in your array