I'm trying to convert this:

for(int i=0; i<5; ++i)
    for(int j=0; j<5; ++j)
        for(int k=0; k<5; ++k)
            cout << i+1 << j+1 << k+1 << endl;

Into a recursive function. I came up with:

void permute(int n){

        for(int i=0; i<5; ++i){

                A[n]=i+1;

                if(n<3){
                        permute(n+1);
                } else {
                        for(int j=0; j<3; ++j)
                                cout << A[j];
                        cout << endl;
                }
        }
}

Where int A[3] is defined globally. But it doesn't work. I'm in the
shadows here, can anyone give me a clue?

Reply via email to