Created
March 31, 2017 00:44
-
-
Save marcoscastro/dadf2d2a5cdde333c82a882456b68d28 to your computer and use it in GitHub Desktop.
C++ - Lista de vetores
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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