1for(auto lst : vec){
2 for(auto e : lst){
3 cout<<e<<" ";
4 }
5 cout<<endl;
6}
1 for(int i=0; i<v.size(); i++)
2 for(int j=0; j<v[i].size(); j++)
3 cout<<v[i][j]<<" ";
4 cout<<endl;
1for( auto &row : arr) {
2 for(auto col : row)
3 cout << col << " ";
4 cout<<endl;
5}
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}
1// A recursive function able to print a vector
2// of an arbitrary amount of dimensions.
3template<typename T>
4static void show(T vec)
5{
6 std::cout << vec;
7}
8
9
10template<typename T>
11static void show(std::vector<T> vec)
12{
13 int size = vec.size();
14 if (size <= 0) {
15 std::cout << "invalid vector";
16 return;
17 }
18 std::cout << '{';
19 for (int l = 0; l < size - 1; l++) {
20 show(vec[l]);
21 std::cout << ',';
22 }
23 show(vec[size - 1]);
24 std::cout << '}';
25}