Skip to content

Instantly share code, notes, and snippets.

@kiroma
Last active July 17, 2018 22:07
Show Gist options
  • Save kiroma/07834abd070661b744c22271e5a1e718 to your computer and use it in GitHub Desktop.
Save kiroma/07834abd070661b744c22271e5a1e718 to your computer and use it in GitHub Desktop.
#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