Answers for "creating a 2d vector in c++"

C++
3

2d vector c++ declaration

vector< vector<int>> a(rows, vector<int> (cols));
Posted by: Guest on January-02-2021
5

initialise 2d vector in c++

// Initializing 2D vector "vect" with 
// values 
vector<vector<int> > vect{ { 1, 2, 3 }, 
                           { 4, 5, 6 }, 
                           { 7, 8, 9 } };
Posted by: Guest on May-16-2020
0

how to take input in 2d vector in c++

std::vector<vector<int>> d;
//std::vector<int> d;
cout<<"Enter the N number of ship and port:"<<endl;
cin>>in;
cout<<"Enter preference etc..:n";
for(i=0; i<in; i++){ 
cout<<"ship"<<i+1<<":"<<' ';
    for(j=0; j<in; j++){
    cin>>temp;
    d.push_back(temp);// I don't know how to push_back here!!
    }
}
Posted by: Guest on July-14-2020

Browse Popular Code Answers by Language