#include <iostream>
#include <vector>
int main() {
// Step 1: Declare a 2D vector
std::vector<std::vector<int>> twoDVector;
// Step 2: Declare inner vectors and push them into the 2D vector
std::vector<int> innerVector1 = {1, 2, 3};
std::vector<int> innerVector2 = {4, 5, 6};
std::vector<int> innerVector3 = {7, 8, 9};
twoDVector.push_back(innerVector1);
twoDVector.push_back(innerVector2);
twoDVector.push_back(innerVector3);
// Step 3: Access and modify elements in the 2D vector
int element = twoDVector[1][2]; // Access element in the second row, third column
twoDVector[0][1] = 10; // Modify element in the first row, second column
// Step 4: Display the contents of the 2D vector
for (const auto &row : twoDVector) {
for (int value : row) {
std::cout << value << " ";
}
std::cout << std::endl;
}
return 0;
}