how to iterate over 2d vector c 2b 2b

Solutions on MaxInterview for how to iterate over 2d vector c 2b 2b by the best coders in the world

showing results for - "how to iterate over 2d vector c 2b 2b"
Brayan
08 Aug 2016
1#include<iostream>
2#include<vector>
3using namespace std;
4/*
5Iterate over vector of vectors and for each of the 
6nested vector print its contents
7*/
8template <typename T>
9void print_2d_vector(const vector< vector<T> > & matrix)
10{
11    for(auto row_obj : matrix)
12    {
13        for (auto elem: row_obj)
14        {
15            cout<<elem<<", ";
16        }
17        cout<<endl;
18    }
19    cout<<endl;
20}