vector of vectors in c code example
Example 1: get values from a vector of vectors c++
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<vector<int> > buff;
for(int i = 0; i < 10; i++)
{
vector<int> temp;
for(int j = 0; j < 10; j++)
temp.push_back(i);
buff.push_back(temp);
}
for(int i = 0; i < buff.size(); ++i)
{
for(int j = 0; j < buff[i].size(); ++j)
cout << buff[i][j];
cout << endl;
}
return 0;
}
Example 2: how to create a vector from elements of an existing vector in cpp
vector<int> vect1{1, 2, 3, 4};
vector<int> vect2;
vect2.assign(vect1.begin(), vect1.end());