I tried my best but I can't figure out the problem. At the last part of "createArray", I output the final array created. I mean it to repeat once but then it repeat more times than I expect. createArray is an iterative function. If it repeats 3 times, than at last the array created which fulfil the criterion would be printed out 3+1 times.
I am trying to create an array with 3 numbers 5 times, resulting in a 2D array. The 3 numbers in a array are picked from 0 - 5. I enter createArray(5,3,5). Then these 5 arrays are compared with each other to see if there are repetitions. If there are, the whole process begins again, 5 arrays with 3 numbers each will be picked again and compared with each other. If there are no repetitions at last, there 5 arrays would be printed out.
#include <algorithm>
#include <iterator>
void deleteArray(int** array){
    delete[] array;
 }
int** createArray(int simu_times, int randomrun,int numberofrun){
    vector<Int_t>fChosenRun;
    int** Array = new int*[simu_times];
    for(int i = 0; i < simu_times; ++i) {
        fChosenRun=getRandom(1,randomrun,numberofrun);
        Array[i] = new int[randomrun]; 
        for(int j = 0; j < randomrun; ++j){ 
            Array[i][j] = fChosenRun[j];     
        }
    }
in the following doubly-nested loop, I compare the arrays with each other. If there are any repetitions, this array would be deleted and createArray is called to create the arrays again.
    for(int j=0;j<simu_times;++j){    
        for(int i=0+j;i<simu_times;++i){
            if(j!=i) {
                if (std::equal(Array[j], Array[j]+ sizeof Array[j] / sizeof *Array[j], Array[i])){
                    cout<<"same: "<< j<<"   "<<i<<endl;
                    deleteArray(Array);
                    createArray(simu_times,randomrun,numberofrun);
                }
            }
        }
    }
When the arrays have no repetition, they would be printed out. All arrays should be printed out once, but they are printed out many times.
    for(int i=0;i<simu_times;++i){
        for(int j=0;j<randomrun;++j){
            cout<< i<<"   "<<j<<"   "<<Array[i][j]<<endl;;
       }
        cout<<endl;
    }
    return Array;
}
 
    