#include <iostream>
int main()
{
int width = 4, height = 4, depth = 4;
int arr[width * height * depth];
for (int i = 0, l = 0; i < depth; ++i)
{
for (int j = 0; j < height; ++j)
{
for (int k = 0; k < width; ++k)
{
arr[k + width * (j + depth * i)] = l++;
}
}
}
for (int i = 0; i < depth; ++i)
{
for (int j = 0; j < height; ++j)
{
for (int k = 0; k < width; ++k)
{
int** ptr = reinterpret_cast<int**>(&arr[0] + width * (j + depth * i));
std::cout<<ptr[j][k];
}
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4oKQp7CiAgICBpbnQgd2lkdGggPSA0LCBoZWlnaHQgPSA0LCBkZXB0aCA9IDQ7CgogICAgaW50IGFyclt3aWR0aCAqIGhlaWdodCAqIGRlcHRoXTsKCiAgICBmb3IgKGludCBpID0gMCwgbCA9IDA7IGkgPCBkZXB0aDsgKytpKQogICAgewogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgaGVpZ2h0OyArK2opCiAgICAgICAgewogICAgICAgICAgICBmb3IgKGludCBrID0gMDsgayA8IHdpZHRoOyArK2spCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGFycltrICsgd2lkdGggKiAoaiArIGRlcHRoICogaSldID0gbCsrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgZGVwdGg7ICsraSkKICAgIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IGhlaWdodDsgKytqKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChpbnQgayA9IDA7IGsgPCB3aWR0aDsgKytrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQqKiBwdHIgPSByZWludGVycHJldF9jYXN0PGludCoqPigmYXJyWzBdICsgd2lkdGggKiAoaiArIGRlcHRoICogaSkpOwogICAgICAgICAgICAgICAgc3RkOjpjb3V0PDxwdHJbal1ba107CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIDA7Cn0=