Last active
July 17, 2018 22:07
-
-
Save kiroma/07834abd070661b744c22271e5a1e718 to your computer and use it in GitHub Desktop.
This file contains 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> | |
int main() | |
{ | |
const int r = 3, c = 3; | |
std::vector<std::vector<int>> testvec; // Create a vector holding vectors holding ints | |
for(int i = 0; i < r; ++i) | |
{ | |
std::vector<int> tempvec; // Create a temporary vector holding ints | |
for(int j = 0; j < c; ++j) | |
{ | |
tempvec.push_back(j); // Fill the temporary vector | |
} | |
testvec.push_back(tempvec); // Push_back the temporary vector into the main vector | |
} | |
for(auto a : testvec) // Type out the contents of the vectors | |
{ | |
for(auto b : a) | |
{ | |
std::cout << b; | |
} | |
std::cout << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment