mardi 6 avril 2021

How to dynamically create a 2d vector

vector< vector<int>> arr(n); arr is a 2d vector. I want to take input "columns" from user and then the elements.

    for(int i=0;i<n;i++)
    {
        int cols; cin>>cols;
        
        //Statements
    }

How shall I create the cols sized vector inside that for loop?

Aucun commentaire:

Enregistrer un commentaire