input 2d vector c++

#include <iostream>
#include <vector>

int main() {
    // Step 1: Declare a 2D vector
    std::vector<std::vector<int>> twoDVector;

    // Step 2: Input the number of rows and columns
    int numRows, numCols;
    std::cout << "Enter the number of rows: ";
    std::cin >> numRows;
    std::cout << "Enter the number of columns: ";
    std::cin >> numCols;

    // Step 3: Resize the 2D vector based on user input
    twoDVector.resize(numRows, std::vector<int>(numCols));

    // Step 4: Input elements into the 2D vector
    std::cout << "Enter elements row-wise:\n";
    for (int i = 0; i < numRows; ++i) {
        for (int j = 0; j < numCols; ++j) {
            std::cout << "Enter element at position (" << i << ", " << j << "): ";
            std::cin >> twoDVector[i][j];
        }
    }

    // Step 5: Display the 2D vector
    std::cout << "Entered 2D vector:\n";
    for (int i = 0; i < numRows; ++i) {
        for (int j = 0; j < numCols; ++j) {
            std::cout << twoDVector[i][j] << " ";
        }
        std::cout << "\n";
    }

    return 0;
}