Subset using binary. No idea

This program is supposed to print out the subsets A-G. I'm supposed the write the code for the selectSubset() and printSubset() functions. It's supposed to do through what my teacher calls "binary mapping". I honestly have no idea how to write this code. Any help would be greatly appreciated

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 #include <iostream>
#include <string>
using namespace std;

int selectSubset(char set[], int binaryMap[], char subset[]);
void printSubset(char subset[], int length);
void add1ToBinary(int bin[]);


int main()
{
  int  i, length, 
       binaryMap[7] = {};
  char subset[7], 
       set[7] = {'a','b','c','d','e','f','g'}; 

  for(i=0; i < 128; ++i){
     length = selectSubset(set, binaryMap, subset);
     printSubset(subset, length);
     add1ToBinary(binaryMap);
  }
}

int selectSubset(char set[], int binaryMap[], char subset[])
{
}


void printSubset(char subset[], int length)
{
}


void add1ToBinary(int bin[7])
{
  int i;

  for(i = 6; i >= 0; --i){
     bin[i] = (bin[i] + 1) % 2;
     if(bin[i] == 1)
        break;
  }
}
Last edited on
Topic archived. No new replies allowed.