Say, I have a 1d array with 30 elements:
array1d[0] = 1
array1d[1] = 2
array1d[2] = 3
.
.
.
array1[29] = 30
How to convert the 1d array to 2d array?
Say 10x3?
array2d[0][0] = 1 array2d[0][1] =2 array2d[0][2] =3
.
.
.
array2d[9][0] = 28 array2d[9][1] =29 array2d[9][2] =30
Should I use a for loop?
But I cannot work it out.
Without writing any code for you...
So it will look something like...
I'm being intentionally vague, seeing as this is homework. Try posting some code so we can see where you get stuck.
Here a generic function to convert from 1D -> 2D array:
If you want to do the contrary (2D -> 1D), here the function:
You can't "convert" a 1D array to a 2D array, but an array can be multi-dimensionnal when you declare it.