define vector of vector in c++ code example
Example: vector of vectors c++
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n = 5;
int m = 7;
//Create a vector containing n vectors of size m and initalize them to 0.
vector<vector<int>> vec(n, vector<int>(m, 0));
for (int i = 0; i < vec.size(); i++) //print them out
{
for (int j = 0; j < vec[i].size(); j++)
{
cout << vec[i][j] << " ";
}
cout << endl;
}
}