I appear to need some help with a sudoku solver I'm working on. It's supposed to check the row, column, and grid. When I run my program it displays the puzzle, but then it ends abruptly. I was hoping someone can take a look at my functions and see if I'm doing something wrong.
void Sudoku::Row(int ptx,int pty)
{
int e=0;
flag=1;
for(int d=0;d<8;d++)
{
for(;e<8;e++)
{
if(Puzzle[d][pty]==Possible[e])
{
remains--;
int f=e;
while(e!=8)
{
Possible[f]=Possible[f+1];
f++;
}
}
}
e=0;
}
cout<<"
if (remains==1)
{
Update(ptx,pty);
}
return;
}
void Sudoku::Column(int ptx,int pty)
{
int g=0;
flag=1;
for(int f=0;f<8;f++)
{
for(;g<8;g++)
{
if(Puzzle[ptx][f]==Possible[g])
{
remains--;
int h=g;
while(g<9)
{
Possible[h]=Possible[h+1];
h++;
}
}
}
g=0;
}
if (remains==1)
{
Update(ptx,pty);
}
return;
}
void Sudoku::Grid(int ptx,int pty)
{
flag=1;
int top,left;
top=(pty/3)*3;
left=(ptx/3)*3;
for(int h=0;h<3;h++)
{
for(int i=0;i<3;i++)
{
for(int j=0;j<9;j++)
{
if(Puzzle[left+i][top+h]==Possible[j])
{
remains--;
int k=j;
while(j<9)
{
Possible[j]=Possible[j+1];
j++;
}
j=k;
}
}
int j=0;
}
int i=0;
}
if (remains==1)
{
Update(ptx,pty);
}
return;
}
void Sudoku::Update(int ptx,int pty)
{
flag=0;
if (Puzzle[ptx][pty]==0)
{
Puzzle[ptx][pty]=Possible[0];
Fill_9(); //fills "possibilities" array with 1-9
}
else
{
cout<<"|-=ERROR=-| That space is already filled."<<endl;
}
Display();
return;
}
I've been staring at this program for so long I've gotten sick of it already and I'm probably making a really dumb mistake. Any help would be really great.