Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6322511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:20:44+00:00 2026-05-24T16:20:44+00:00

I have a list of list . All elements will be inserted at run-time.

  • 0

I have a list of list . All elements will be inserted at run-time. i wish to try all combinations through all list. So the simple solution comes to mind as

for ( l1 in L1)   
{   for ( l2 in L2)   
    { for ( l3 in L3)  
          { 
               ... // use the pair (l1,l2,l3) 
          }
    }
}

But i dont know the number of fors required at compile time. So how do i iterate through all pairs within c++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:20:45+00:00Added an answer on May 24, 2026 at 4:20 pm

    Use recursion.

    typedef std::list<std::list<int>> ListOfList;
    
    void actOnHelper(ListOfList::const_iterator c, ListOfList::const_iterator end, std::list<int> v)
    {
       if (c == e) {
          // do something on v
       } else {
          ListOfList::const_iterator nextc(c);
          ++nextc;
          for (std::list<int>::const_iterator i = c->begin(), e = c->end(); i != e; ++i) {
            v.push_back(*i);
            actOnHelper(nextc, end, v);
            v.pop_back();
         }
       }
    }
    void actOn(std::list<std::list<int>> const& l)
    {
       actOnHelper(l.begin(), l.end(), std::list<int>());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to search through a list and replace all occurrences of one element
I would like to have a list of all the time zones available on
I'm looking for a ClearCase command that will list all the elements that are
I will have four word list arrays. $array1 = array('red','blue','green');//it can have more elements
I forgot the jQuery command that will clear all list elements from a list.
$('.footnote').clone().appendTo('#allfootnotes').append('<br>'); I have a bunch of .footnote elements all through the page, at the
If I have List<String> text how can I create a sub-list of all continious
Say I have a list of all Projects , and that I group them
Is there any way to list all the files that have changed between two
I need to have a query which list all the user according to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.