avr39ripe

SBU2dArrayBasics

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