Answers for "2d array c++ vector"

C++
1

how to create 2d array using vector in c++

vector<vector<int>> vec(N, vector<int> (M, INT_MAX));

Explanation::
vector<vector<int>> -- will take the formed container
N -- Think like row of 2d Matrix
vector<int> (M, INT_MAX) -- In each row, there is again a vector associated with it, 
that will formed 2d array.
Posted by: Guest on July-13-2021

Browse Popular Code Answers by Language