avr39ripe

cppArr2DBase

Apr 6th, 2021
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.    
  6.     const int arrSizeY{ 4 };
  7.     const int arrSizeX{ 4 };
  8.  
  9.     const int arrSize{ arrSizeY * arrSizeX };
  10.  
  11.     int arrFlat[arrSizeX]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
  12.  
  13.     int arr[arrSizeY][arrSizeX]{ {1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16} };
  14.  
  15.     for (int y{ 0 }; y < arrSizeY; ++y)
  16.     {
  17.         for (int x{ 0 }; x < arrSizeX; ++x)
  18.         {
  19.             std::cout << arr[y][x] << '\t';
  20.         }
  21.         std::cout << '\n';
  22.     }
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment