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}
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}