This is a small part that I've been stuck on, and it's part of a much larger assignment.
I have a 2D vector such as:
v1: 0 1 2 3 4
v2: 0 1 2
v3: 0 1 2 3 4
v4: 0 1 2 3
v5: 0 1 2 3 4
(each row is a vector)
I need to find all the permutations, choosing one element from each row. As someone pointed out, this would be the cartesian product.
I tried using loops, but that will only work in one direction (it misses quite a few permutations)
I also looked into next_permutation, but I'm not sure if it's possible to apply this to a 2D vector.
Additionally, the number of rows is not static, so I cannot nest 5 loops, as there could be more or less rows depending on the conditions.
Is there a way to do this?