+ 1
what is the use of multi-dimensional arrays if we can do that work in single-dimentional array also?
3 Respuestas
+ 1
In my openion,
using a multidimensional array helps you to shorten the code, as it helps us to create a single entity instead of multiple entities.
for e.g.,
int area_rectangle = new int[3][3];
now you can use this single "area_rectangle"for your calculation.
whereas, with single dimensional array you will have to create one array for length, and another for breadth.
In other words, it's just to make life easier for the developer in certain circumstances while the underlying data is still in the form of single dimensional array.
0
Convenience. I prefer to type arr[i][j] rather than arr[i*row_size+j]. How about you?
0
The people who get confused with multi-dimensional arrays use single arrays. multi-dimensional arrays is quite confusing especially if you are new to arrays.
For short codes and faster programs, multi-dimentional arrays are neccessary especially when it has to deal with large programs involving several encryption / decryption algorithms.