+ 1
Why it is necessary to mention the column dimension where row dimension is optional?
In array declaration
2 Respostas
+ 1
Look at my code example;
https://code.sololearn.com/c2DwRSriSSl0/?ref=app
A 2D array could be initialized with a fully bracketed definition e.g.
{ {1, 2, 3}, {4, 5, 6} }
or with a simple sequence of values e.g.
{1, 2, 3, 4, 5, 6}
(see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf chapter 6.7.9 paragraph 26)
If you choose the second way, the notation
arr[][] = {1, 2, 3, 4, 5, 6}
would be ambiguous. It could be understood as
{ {1, 2, 3}, {4, 5, 6} }
or
{ {1, 2}, {3, 4}, {5, 6} }
So the only value that can be omitted during multidimensional array initialization is the leftmost bracket value.