+ 3
Does anyone know how to implement in C++ the cartesian product of 2 vectors using lists?
I would apreciate a solution or some advice to solve this problem
7 ответов
+ 4
The cartesian product is just combining every element from one list with every element from the other.
If your lists are called `as` and `bs`:
for(auto a : as){
for(auto b : bs){
result.push_back(make_pair(a,b));
}
}
+ 1
Well you can use any type of loop or list you want.
What I am saying is that it's two loops inside each other, where you run through the vectors.
What part of the assignment is giving you trouble?
0
Is this c++? I dont think i ve seen this before 😅😅
0
Combining the 2 vectors into 1 pair using the list
0
I know that i need 2 loop cycles but the implementing itself its tricky
0
This is how i tried to do it