+ 1
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4
in this syntax we didn't declare 3 dimension array so what is the position of 4 and why?And how it is 3*3 array if it is 2 dimensional
1 Odpowiedź
+ 10
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} };
// declares a 2D, 3x3 array in the form of
1 2 3
4 - -
5 6 7
myArr[1][0] will correspond to the second row, first column, which is 4.