Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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;
- }
Add Comment
Please, Sign In to add comment