Help: To make all combinations of binary sequence

Discussion in 'C++' started by The_Prince, Aug 31, 2010.

  1. The_Prince

    The_Prince New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I have a problem which has been puzzling me for a few days. i have been trying it with vectors and characters but will not work for me. Imagine an "ON" "OFF" binary sequence. I want to compute all combinations of that sequence of length N say.

    e.g sequence 001011 of length 6, but want all possibilities arising of length 6

    I was thinking about using the class and defining for example

    std::bitset
    Is this the best way for a sequence of "ON" "OFF" code? Then from here what is the best way to make sure all the possibilities of the sequence can be generated?


    (( On a side note, I can't have for instance "std::bitset" where N is user defined or defined elsewhere. The error is 'expression must have a constant value' so I think its something to do with address?))

    Thanks for your time in reading if you have gotten this far.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice