Howto create combinations of several vectors without hardcoding loops in C++?

前端 未结 10 1015
慢半拍i
慢半拍i 2020-11-29 08:40

I have several data that looks like this:

Vector1_elements = T,C,A
Vector2_elements = C,G,A
Vector3_elements = C,G,T
..... up to ...
VectorK_elements = ...

         


        
10条回答
  •  心在旅途
    2020-11-29 09:10

    This will do the trick:

    void printAll(const vector > &allVecs, size_t vecIndex, string strSoFar)
    {
        if (vecIndex >= allVecs.size())
        {
            cout << strSoFar << endl;
            return;
        }
        for (size_t i=0; i

    Call with:

    printAll(allVecs, 0, "");
    

提交回复
热议问题