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 3393036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:00:10+00:00 2026-05-18T04:00:10+00:00

For given n inputs, I need to generate all possible input combinations using C++

  • 0

For given n inputs, I need to generate all possible input combinations using C++

eg. n =4

I need to get,

1010101010101010

1100110011001100

1111000011110000

1111111100000000

(EDIT : In case this is not clear, these are the input combinations read column-wise)

I need these to perform operations like & and | so it would be best if I get them in their integer representation as n different variables.

I tried doing it using bitset for 32 input combinations but it took a long time to process. I was hoping if you guys had any ideas on a better implementation?

EDIT : Example when n=3

10101010

11001100

11110000
  • 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-18T04:00:11+00:00Added an answer on May 18, 2026 at 4:00 am

    Here is a short implementation that generates that output:

    void print_mask(int n){
        for (int level = 0; level < n; level++){
            for (int i = (1<<n)-1; i>=0; i--)   // we'll always output 2**n bits
                printf("%d", (i >> level) & 1);
            printf("\n");
        };
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this input: [1,2,3,4] I'd like to generate the set of spanning sets: [1]
By which I mean this: Given the input set of numbers: 1,2,3,4,5 becomes 1-5.
I was looking into sorting tables by a column designated given some input, and
I am attempting to compose a style sheet that, given an XML input (obviously)
Given following Ruby statements: (Read input and store each word in array removing spaces
I have rather large input XML files that must be converted to a given
I'm trying to get console input in my Clojure program, but when it gives
I'm looking for a way to programmatically recreate the following effect: Give an input
I'm trying something like this Output.py print Hello Input.py greeting = raw_input(Give me the
Given a specific DateTime value, how do I display relative time, like: 2 hours

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.