combination program

i'm currently trying to write a combination program.
And my program won't work until SIZE >= 19
error:
Process returned -1073741819 (0xC0000005)
using Code::Block 8.02
Please help!Thanks!

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include <fstream>
using namespace std;
ofstream dt("records.txt"); // result
const int SIZE = 19; // size 18 still works

void output(char *A, bool *B) {
    for(int i = 0; i < SIZE; ++i) {
        if(B[i]) {
            dt << A[i] <<" ";
        }
    }
    dt << endl;
}

void recur(char *A, bool *B, int a, int b, int x) {
    if(a < x) {
        output(A, B);
        B[a] = false;
        if(a + 1 < x) {
            B[a + 1] = true;
            recur(A, B, a + 1, b, x);
        } else {
            int i = a - 1, j = 1;
            for(; i >= 0; --i) {
                if(B[i]) {
                    B[i] = false;
                    ++j;
                } else {
                    break;
                }
            }
            if(i >= 0) {
                for(; i >= 0; --i) {
                    if(B[i]) {
                        break;
                    }
                }
                if(i >= 0) {
                    B[i] = false;
                    ++j;
                    for(++i; i < x; ++i) {
                        B[i] = true;
                        --j;
                        if(!j) {
                            break;
                        }
                    }
                    if(i < x) {
                        recur(A, B, i, b, x);
                    }
                }
            }
        }
    }
}

void run2(char *A, bool *B, int x) {
    B[x] = true;
    output(A, B);
    for(int i = 0; i < x; ++i) {
        for(int j = 0; j <= i; ++j) {
            B[j] = true;
        }
        recur(A, B, i, i + 1, x);
        for(int j = 0; j <= i; ++j) {
            B[j] = false;
        }
    }
    B[x] = false;
}

void run(char *A, bool *B) {
    for(int i = 0; i < SIZE; ++i) {
        run2(A, B, i);
    }
}

int main() {
    bool B[SIZE]; // mark the item
    char A[SIZE]; // A to Z
    for(int i = 0; i < SIZE; ++i) {
        A[i] = (char)(i + 'A');
        B[i] = false;
    }

    run(A, B); //combination
    cout << "done" << endl;
    system("pause");

    return 0;
}
This is quite honestly a bit of a mess. Please elaborate on what you mean when you say you are trying to write a "Combination Program". I'm finding this following your functions that contain loops for other functions a bit frustrating.
Ok, I broke down and compiled your app. You're trying to make a rainbow table? You start off with a pretty good approach, but then I can tell where you had trouble and started throwing in code "just so that part works". There are better ways to do this, I'll be doing something simular now that you've put the idea in my head so please if you have more questions ask away.

This works fine for me on wxDev-C++ with MingW. Try restarting Code::Blocks, I've noticed with some stuff that I do in it the shell it uses to run your app doesn't always close properly. Let us know if you're still having this issue.
@Computergeek01 ,
Hi:
I am trying to make it clear on what i meant here... (sorry!)
if i got a transaction "ABCD", then i want to generate all the combinations
that means {A} {B}{C}{D}{AB} .... {ABCD}
under my my method, i wanna generate combinations in a different way.
"a new generated itemset must guarantee the subsets of an itemset should've already generated"
Example: {ABCD}
A
B
AB ( the subset of AB had already generated)
C
AC
BC
ABC
D
AD
BD
CD
ABD
ACD
BCD
ABCD

I restarted Code::Blocks, and it still has a issue....
Could it be possible for some bugs on different compilers or something like that?

Topic archived. No new replies allowed.