how to print 2D vector in c++ by stl code example
Example 1: print 2d vector c++
for(int i=0; i<v.size(); i++)
for(int j=0; j<v[i].size(); j++)
cout<<v[i][j]<<" ";
cout<<endl;
Example 2: how to print a 2d array in c++
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cout << arr[i][j] << " ";
}
// Newline for new row
cout << endl;
}