+ 6
Can anyone explain following code
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4
4 odpowiedzi
+ 9
That saves 42 to that element. At the initialization that element was set to 3.
+ 7
Write it down as a table to understand it:
1 2 3 | a [0][0] a [0][1] a [0][2]
4 | a [1][0]
5 6 7 | a [2][0] a [2][1] a [2][2]
+ 2
but why myArr[0][2] = 42;
+ 1
thanks