#include <iostream>
#include <vector>
int main() {
// Step 1: Declare a two-dimensional vector
std::vector<std::vector<int>> twoDVector;
// Step 2: Declare the size of the first dimension (rows)
int numRows = 3;
// Step 3: Declare the size of the second dimension (columns)
int numCols = 4;
// Step 4: Resize the first dimension with the specified number of rows
twoDVector.resize(numRows);
// Step 5: Resize each row (second dimension) with the specified number of columns
for (int i = 0; i < numRows; ++i) {
twoDVector[i].resize(numCols);
}
// Step 6: Initialize values in the two-dimensional vector
for (int i = 0; i < numRows; ++i) {
for (int j = 0; j < numCols; ++j) {
// Replace 0 with the desired initial value
twoDVector[i][j] = 0;
}
}
// Step 7: Access and modify elements of the two-dimensional vector
int newValue = 42;
twoDVector[1][2] = newValue;
// Step 8: Print the two-dimensional vector
for (int i = 0; i < numRows; ++i) {
for (int j = 0; j < numCols; ++j) {
std::cout << twoDVector[i][j] << " ";
}
std::cout << std::endl;
}
return 0;
}