I would like to fill and then return a vector of vector of sets. In other words a matrix that has a set of numbers into itself. I declared:
#include<iostream>
#include<set>
#include<vector>
vector<int> row = vector<int>(4);
vector<vector<int>> matrix = vector<vector< int>>(4, row)
If it would be a vector of vector of vector I would write
vector<vector<vector<int>>> v = vector<vector<vector<int>>>(4, matrix)
.
Maybe is ok to write vector<vector<set<int>>> v;
for a vec of vec of sets. But I would put that set<int>
into matrix
.
It's a 4x4 matrix, with 4 possible numbers into it. I'm trying to populate v
with numbers from 1 to 4 using v[i][j].insert(f)
iterating f from 0 to 4.
How can I return that matrix printing all numbers too? I would expect something like this:
1234123412341234
1234123412341234
1234123412341234
1234123412341234
Extra question
How can I access and delete numbers into an element of the matrix?
For example I want to access into the second row and third column. I have 1234
and I want to erase 3 of those 4 numbers. Let's say I want to write only 1
in matrix[2][3]
.
I would think it's something like v[2][3].find(1)
but I'm not pretty sure.
Please, don't suggest me to use other stl containers. The only other stl I can use are vectors, set or map and unordered_set or map.