Answers for "initialize a bidimensional array c++"

C++
0

get elements of 2d array c++

void printMatrix(array<array<int, COLS>, ROWS> matrix){
for (auto row : matrix){
//auto infers that row is of type array<int, COLS>
for (auto element : row){
cout << element << ' ';
}
cout << endl;
}
Posted by: Guest on May-25-2020
-3

initialize 2d array c++

#include <array>
2 #include <iostream>
3
4 using namespace std;
5
6 //remember const!
7 const int ROWS = 2;
8 const int COLS = 3;


int main(){
 array<array<int, COLS>, ROWS> matrix = {
 1, 2, 3,
 4, 5, 6
 };
  
  
  return 0;
}
Posted by: Guest on May-30-2020

Code answers related to "initialize a bidimensional array c++"

Browse Popular Code Answers by Language