Define n as:
int n[2][3][3]= {
{{2,7,3},{1,8,7},{5,6,2}},
{{4,5,8},{5,5,6},{2,6,2}}
};
Note that raw arrays in C++ are not good enough. Better use std::array:
std::array<std::array<std::array<int,3>,3>, 2> n = {
{{2,7,3},{1,8,7},{5,6,2}},
{{4,5,8},{5,5,6},{2,6,2}}
};
Well, that looks ugly — use typedef (or alias) to simplify the syntax:
template<typename T, std::size_t M, std::size_t N, std::size_t P>
using array3d = std::array<std::array<std::array<T,P>,N>, M>;
Then use it as:
array3d<int,2,3,3> n = {
{{2,7,3},{1,8,7},{5,6,2}},
{{4,5,8},{5,5,6},{2,6,2}}
};
Thats better.
You could generalize the alias as:
#include <array>
template<typename T, std::size_t D, std::size_t ... Ds>
struct make_multi_array
: make_multi_array<typename make_multi_array<T,Ds...>::type, D> {};
template<typename T, std::size_t D>
struct make_multi_array<T,D> { using type = std::array<T, D>; };
template<typename T, std::size_t D, std::size_t ... Ds>
using multi_array = typename make_multi_array<T,D,Ds...>::type;
Then use it as (read the comments for better understanding):
//same as std::array<int,10>
//similar to int x[10]
multi_array<int,10> x;
//same as std::array<std::array<int,20>,10>
//similar to int y[10][20]
multi_array<int,10,20> y;
//same as std::array<std::array<std::array<int,30>,20>,10>
//similar to int z[10][20][30]
multi_array<int,10,20,30> z;
Hope that helps.
std::arrayis better than raw array except a bit long code. However, if you decide to use that, I recommend you to change your all raw arrays in your code intostd::arrayfor consistency.