If I want to get the Cartesian Product of these two vector
s:
vector final{\"a\",\"b\",\"c\"};
vector temp{
Try the function cartesian:
#include
#include
using namespace std;
void cartesian(vector& f, vector &o) {
int oldfsize = f.size();
f.resize(oldfsize * o.size());
for (int i = o.size() - 1; i>=0; i--) {
for (int j = 0; j < oldfsize; j++) {
f[i*oldfsize + j] = f[j] + o[i];
}
}
}
int main()
{
vector f{"a","b","c"};
vector temp{"1","2"};
cartesian(f, temp);
for (auto &s: f) {
printf("%s\n", s.c_str());
}
}