Power set: Difference between revisions

32 bytes removed ,  14 years ago
m (→‎{{header|MATLAB}}: Fixed one more problem that I forgot to delete.)
Line 181:
int max = 1<<set->count; // Assuming count < 32
 
PowerSet ps = (PowerSet)malloc( sizeof(struct powerSetStruct));
 
if (ps) {
ps->elements = (Set*)malloc( max*sizeof(Set));
ps->count = max;
ps->printer = PrintSet;
Line 191:
for (ix=0; ix<max; ix++) {
int setsize = 0;
Set se = (Set)malloc(sizeof(struct setStruct));
 
for (j=0; j<set->count; j++)
if (ix & (1<<j)) setsize++;
if (setsize > 0) {
se->elements = (SetType *)malloc(setsize *sizeof(SetType));
n = 0;
for (j=0; j<set->count; j++) {
Anonymous user