Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created March 31, 2017 00:44
Show Gist options
  • Select an option

  • Save marcoscastro/dadf2d2a5cdde333c82a882456b68d28 to your computer and use it in GitHub Desktop.

Select an option

Save marcoscastro/dadf2d2a5cdde333c82a882456b68d28 to your computer and use it in GitHub Desktop.
C++ - Lista de vetores
#include <iostream>
#include <vector>
#include <list>
using namespace std;
int main(int argc, char *argv[])
{
// criando os vetores e adicionando elementos aos vetores
vector<int> v1, v2;
v1.push_back(1);
v1.push_back(2);
v2.push_back(3);
v2.push_back(4);
v2.push_back(5);
// criando a lista e adicionando os vetores na lista
list<vector<int> > l;
l.push_back(v1);
l.push_back(v2);
// mostrando todos os elementos
list<vector<int> >::iterator it;
// percorrendo a lista
for(it = l.begin(); it != l.end(); ++it)
{
// percorrendo o vetor
for(unsigned int i = 0; i < it->size(); i++)
{
cout << (*it)[i] << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment