size of 2d vector c++ code example
Example 1: how to get size of 2d vector in c++
myVector[
Vector[0, 4, 2, 5],
Vector[1, 4, 2]
];
Example 2: size of a matrix using vector c++
myVector[0].size();
Example 3: initialising 2d vector
vector<vector<int> > vect{ { 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 } };
Example 4: how to take input in 2d vector in c++
std::vector<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);
}
}