Cartesian product of several vectors

后端 未结 1 1193
天涯浪人
天涯浪人 2020-12-02 02:53

similar questions have been asked before but I cant find an exact match to my question.

I have 4 vectors each of which hold between 200-500 4 digit integers. The ex

相关标签:
1条回答
  • 2020-12-02 03:18

    Not much of an algorithm...

    for(vector<int>::const_iterator i1 = v1.begin(); i1 != v1.end(); ++i1)
        for(vector<int>::const_iterator i2 = v2.begin(); i2 != v2.end(); ++i2)
            for(vector<int>::const_iterator i3 = v3.begin(); i3 != v3.end(); ++i3)
                for(vector<int>::const_iterator i4 = v4.begin(); i4 != v4.end(); ++i4)
                    cout << "[" << *i1 << "," << *i2 << "," << *i3 << "," << *i4 << "]" << endl;
    
    0 讨论(0)
提交回复
热议问题