Answer the question
In order to leave comments, you need to log in
3D array with different sizes of inner arrays?
Hello everyone
. We need to put several two-dimensional arrays of different sizes into one three-dimensional
Example, a[5][6], b[3][7], c[7][2] and somehow make three-dimensional or something else out of them , but so that I can access them all as separate elements of the same array or other data structure.
Is there any way to concatenate arrays like this?
Thanks
Answer the question
In order to leave comments, you need to log in
Use vector<vector<vector<int>>>>
- each row/column can be any size you want.
It is also possible to store your arrays as pointers in a single array of pointers. After all, these sish arrays are, in fact, pointers to the beginning. But in this form, you will have to somehow remember their sizes somewhere and manually calculate the indexing in the form of a[i*6+j], b[i*7+j]
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question