I replaced a 3D array with a 3D std::vector in my code function and it's entering a infinite loop at compiling.If I had used a 3D array arr[ ][ ][ ] it would work perfect.Could you give me a hint,I really need to use a vector instead an array.Thanks:)
My initial code was:
bool sol(int arr[12][12][13]) {
int row,col;
if(!find_empty(arr,row,col)) return true;
for(int i=1;i< arr[row][col].size();i++) {
if(is_working(arr,row,col,arr[row][col][i]) ) {
arr[row][col][0] = arr[row][col][i];
if(sol(arr)) return true;
arr[row][col][0] = 0;
}
}
return false;
}
I replace arr with
std::vector<std::vector<std::vector<int> > > vec;
vec.resize(12);
for(int i=0;i<12;i++)
{
vec[i].resize(12);
for(int j=0;j<12;j++)
{
vec[i][j].resize(13);
for(int k=0;k<13;k++)
vec[i][j][k]=table[i][j][k];
}
}
and now it's entering a infinite loop!The initial code has no errors,it's a simple backtracking.The problem appears after I replace arr with vec.Could you give me some advice.Sorry for the first posting!