Ways to initialise a 2D vector
- vector<vector
>vec(row,vector (col,’#’)); Here row and col are the sizes of the 2D vector along its two axes
- The second way: set the size with resize, then assign values in a loop
vector<vector<char> >vec1; vec1.resize(row); for(int i=0;i<vec1.size();i++) vec1[i].resize(col); for(int i=0;i<row;i++) for(int j=0;j<col;j++) vec1[i][j]='#';