Guest User

Untitled

a guest
Jul 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main()
  5. {
  6. const int r = 3, c = 3;
  7. std::vector<std::vector<int>> testvec; // Create a vector holding vectors holding ints
  8. for(int i = 0; i < r; ++i)
  9. {
  10. std::vector<int> tempvec; // Create a temporary vector holding ints
  11. for(int j = 0; j < c; ++j)
  12. {
  13. tempvec.push_back(j); // Fill the temporary vector
  14. }
  15. testvec.push_back(tempvec); // Push_back the temporary vector into the main vector
  16. }
  17. for(auto a : testvec) // Type out the contents of the vectors
  18. {
  19. for(auto b : a)
  20. {
  21. std::cout << b;
  22. }
  23. std::cout << std::endl;
  24. }
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment