// C++ program to demonstrate the
// working of vector of vectors
// of tuples
#include <bits/stdc++.h>
using namespace std;
// Function to print 2D vector elements
void print(vector<vector<tuple<int,
int, int> > >& myContainer)
{
// Iterating over 2D vector elements
for (auto currentVector : myContainer) {
// Each element of the 2D vector
// is a vector itself
vector<tuple<int, int, int> > myVector
= currentVector;
// Iterating over the vector elements
cout << "[ ";
for (auto currentTuple : myVector) {
// Print the element
cout << "{";
cout << get<0>(currentTuple)
<< ", " << get<1>(currentTuple)
<< ", " << get<2>(currentTuple);
cout << "} ";
}
cout << "]\n";
}
}
// Driver code
int main()
{
// Declaring a 2D vector of tuples
vector<vector<tuple<int,
int, int> > >
myContainer;
// Initializing vectors of tuples
// tuples are of type {int, int, int}
vector<tuple<int, int, int> > vect1
= { { 1, 1, 2 }, { 2, 2, 4 }, { 3, 3, 6 }, { 4, 4, 8 } };
vector<tuple<int, int, int> > vect2
= { { 1, 2, 3 }, { 1, 3, 4 }, { 1, 4, 5 }, { 1, 5, 6 } };
vector<tuple<int, int, int> > vect3
= { { 4, 5, 2 }, { 8, 1, 9 }, { 9, 3, 1 }, { 2, 4, 8 } };
vector<tuple<int, int, int> > vect4
= { { 7, 2, 1 }, { 6, 5, 1 }, { 1, 2, 9 }, { 10, 4, 8 } };
// Inserting vector of tuples in the 2D vector
myContainer.push_back(vect1);
myContainer.push_back(vect2);
myContainer.push_back(vect3);
myContainer.push_back(vect4);
// Calling print function
print(myContainer);
return 0;
}