Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int arrSizeY{ 4 };
- const int arrSizeX{ 4 };
- const int arrSize{ arrSizeY * arrSizeX };
- int arrFlat[arrSize]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
- int arr[arrSizeY][arrSizeX]{ {1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16} };
- for (int y{ 0 }; y < arrSizeY; ++y)
- {
- for (int x{ 0 }; x < arrSizeX; ++x)
- {
- //std::cout << arr[y][x] << '\t';
- std::cout << arrFlat[y * arrSizeX + x] << '\t';
- }
- std::cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement