0

Can sm explain me 3D array and 4D array?

24th May 2019, 5:09 AM
#peace
#peace - avatar
17 Respuestas
+ 1
What do you mean
25th May 2019, 11:18 AM
Airree
Airree - avatar
+ 1
That code is private, and you should do it like this: int arr3d[][][] instead of: int[][][] arr3d I'm sorry, but I get all the languages mixed up sometimes
25th May 2019, 11:27 AM
Airree
Airree - avatar
+ 1
If you want that many elements, yes
25th May 2019, 11:33 AM
Airree
Airree - avatar
0
Well, first you should understand 1D and 2D arrays. A 1 dimensional array is just a normal array (like int[] arr1d). A 2 dimensional array is an array, containing another array: [1, 2, [3, 4, 5]] You should declare it like this: int[][] arr2d. You can access its elements like this: cout << arr2d[2][2]; //Outputs 4 More than two dimensional arrays don't need explanation, it's pretty obvious after that. 3D: int[][][] arr3d = [1, [2, [3, 4, 5]]]; arr3d[1][1][2] == 5 ...
24th May 2019, 5:27 AM
Airree
Airree - avatar
0
I'm sorry, are you sure that declared correctly?
24th May 2019, 5:42 AM
#peace
#peace - avatar
0
Is it like that int arr [2][2]={{1,2},/*0 row*/ {3,4}};/*1row*/ cout << arr [2][2]; // Outputs 0
24th May 2019, 5:46 AM
#peace
#peace - avatar
0
Okay, I used brackets instead of curly brackets, but you get the point
24th May 2019, 5:47 AM
Airree
Airree - avatar
0
Not fully
24th May 2019, 5:54 AM
#peace
#peace - avatar
0
I do know 2d arr very well, but 3d and 4D is little bit complex for me
24th May 2019, 5:55 AM
#peace
#peace - avatar
0
Anyway thxs for explanation
25th May 2019, 11:17 AM
#peace
#peace - avatar
0
Btw Airree u explained me incorrectly
25th May 2019, 11:17 AM
#peace
#peace - avatar
0
Look at my codes .There s code "3D array". Maybe through that you will see your mistake
25th May 2019, 11:24 AM
#peace
#peace - avatar
0
Ok
25th May 2019, 11:31 AM
#peace
#peace - avatar
0
You mean that I should declare like this: int [2][3][4] arr3D
25th May 2019, 11:32 AM
#peace
#peace - avatar
0
?
25th May 2019, 11:32 AM
#peace
#peace - avatar
0
Got.
25th May 2019, 11:34 AM
#peace
#peace - avatar
0
Let me just understand better through the coding
25th May 2019, 11:35 AM
#peace
#peace - avatar