Simple 3D Array C++

后端 未结 5 1583
深忆病人
深忆病人 2021-02-05 13:57

I am a novice in C++ and I am trying to create a simple static 3 Dimensional Array and then print it out in console.

Here is my current code:

#include &l         


        
5条回答
  •  醉梦人生
    2021-02-05 14:34

    Change the code as per following. You can see there are 2 groups containing two tuples each having two elements in it.

     int MyArray[MAX_ROW][MAX_COL][MAX_HEIGHT] = { 
                                                   { {1,1},{2,10} }, 
                                                   { {4,20},{5,25} } 
                                                 };
    

    Have a look in following example to make it more clear

      int arr[2][3][4] = { 
                           { {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4} },
                           { {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4} } 
                         };
    

    As you can see, there are two groups, each containing three groups of 4 numbers.

提交回复
热议问题