Answers for "how to iterate over 2d vector c++"

C++
1

how to iterate over 2d vector c++

#include<iostream>
#include<vector>
using namespace std;
/*
Iterate over vector of vectors and for each of the 
nested vector print its contents
*/
template <typename T>
void print_2d_vector(const vector< vector<T> > & matrix)
{
    for(auto row_obj : matrix)
    {
        for (auto elem: row_obj)
        {
            cout<<elem<<", ";
        }
        cout<<endl;
    }
    cout<<endl;
}
Posted by: Guest on May-15-2021

Code answers related to "how to iterate over 2d vector c++"

Browse Popular Code Answers by Language