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