1myVector[
2 Vector[0, 4, 2, 5],
3 Vector[1, 4, 2]
4];
5
6/*When you call for myVector[1].size() it would return 3 and [0] would return 4.
7
8For the amount of rows (int vectors) in the 2d vector, you can just use myVector.size()
9
10You can run this to see it in actions*/
1// Initializing 2D vector "vect" with
2// values
3vector<vector<int> > vect{ { 1, 2, 3 },
4 { 4, 5, 6 },
5 { 7, 8, 9 } };
1std::vector<vector<int>> d;
2//std::vector<int> d;
3cout<<"Enter the N number of ship and port:"<<endl;
4cin>>in;
5cout<<"\Enter preference etc..:\n";
6for(i=0; i<in; i++){
7cout<<"ship"<<i+1<<":"<<' ';
8 for(j=0; j<in; j++){
9 cin>>temp;
10 d[i].push_back(temp);
11 }
12}
1vector<vector<int> > d;
2int val;
3for(int i = 0; i < in; i++){
4 vector<int> temp;
5 for(int j = 0; j < in; j++){
6 cin >> val;
7 temp.push_back(val);
8 }
9 d.push_back(temp);
10 temp.clear();
11}
12From SpyrosD3v25
1vector<vector<int> > d;
2int val;
3for(int i = 0; i < in; i++){
4 vector<int> temp;
5 for(int j = 0; j < in; j++){
6 cin >> val;
7 temp.push_back(val);
8 }
9 d.push_back(temp);
10 temp.clear();
11}
12
1std::vector<vector<int>> d;
2//std::vector<int> d;
3cout<<"Enter the N number of ship and port:"<<endl;
4cin>>in;
5cout<<"\Enter preference etc..:\n";
6for(i=0; i<in; i++){
7cout<<"ship"<<i+1<<":"<<' ';
8 for(j=0; j<in; j++){
9 cin>>temp;
10 d.push_back(temp);// I don't know how to push_back here!!
11 }
12}