#include <iostream>
#include <vector>
int main() {
int rows, cols;
// Step 1: Input the number of rows and columns
std::cout << "Enter the number of rows: ";
std::cin >> rows;
std::cout << "Enter the number of columns: ";
std::cin >> cols;
// Step 2: Declare a 2D vector with the specified dimensions
std::vector<std::vector<int>> matrix(rows, std::vector<int>(cols));
// Step 3: Input elements into the 2D vector
std::cout << "Enter elements row-wise:\n";
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
std::cout << "Enter element at position (" << i + 1 << ", " << j + 1 << "): ";
std::cin >> matrix[i][j];
}
}
// Step 4: Display the 2D vector
std::cout << "Entered 2D vector:\n";
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
std::cout << matrix[i][j] << " ";
}
std::cout << "\n";
}
return 0;
}