#include <iostream>
#include <vector>
int main() {
// Step 1: Declare a 2D vector using the vector template with int as the data type.
std::vector<std::vector<int>> my2DVector;
// Step 2: Declare inner vectors to represent rows in the 2D vector.
// Step 3: Populate the inner vectors with integer values to represent columns.
my2DVector.push_back({1, 2, 3});
my2DVector.push_back({4, 5, 6});
my2DVector.push_back({7, 8, 9});
// Step 4: Access and print elements of the 2D vector using nested loops.
for (size_t i = 0; i < my2DVector.size(); ++i) {
for (size_t j = 0; j < my2DVector[i].size(); ++j) {
std::cout << my2DVector[i][j] << " ";
}
std::cout << std::endl;
}
return 0;
}