I am having trouble with it, the column double checker works fine at the moment but the row double checker doesn't.

when i run the program and use the double checker for the rows and columns it comes up with

NumOfDoubles_Row = 8

NumOfDoubles_Col = 0

but there shouldn't be 8 doubles in the rows because no numbers have been added yet.

The functions are below:

bool DoublesIn_Row(int SNum[][9], int iS, int &NumOfDoubles_Row) { int RowCheckVar = 0; NumOfDoubles_Row = 0; for(int row = 0; row < iS; row++) { for(int col = 0; col < iS; col++) { RowCheckVar = SNum[row][col]; // assigns the value in SNum[x][y] to the check Variable IsValid_Row(SNum, iS, NumOfDoubles_Row, RowCheckVar, row, col); } } SetCursorPosition(0, 24); std::cout << " No.Doubles: " << NumOfDoubles_Row << std::endl; // only here for testing purposes if(NumOfDoubles_Row != 0) return true; // i realize i probably dont need to have this in here as IsValid returns a boolean but ill fix that later else return false; } bool IsValid_Row(int SNum[][9], int iS, int &NumOfDoubles_Row, int RowCheckVar, int row, int col ) { for(int n = 1; n < iS - 1; n++) { // n is used to iterate over the numbers in a row eg. col = 0, 0 + 1, 0 + 2, 0 + 3. etc. if(RowCheckVar == SNum[row][col + n] && RowCheckVar != 0) NumOfDoubles_Row++; // if check variable is equal to number at SNum[x][y] and the variable is not equal to 0 then add 1 to the number of doubles } if(NumOfDoubles_Row == 0) return true; // return true if there are no doubles in the rows else return false else return false; } bool DoublesIn_Col(int SNum[][9], int iS, int &NumOfDoubles_Col) { int ColCheckVar = 0; NumOfDoubles_Col = 0; for(int row = 0; row < iS; row++) { for(int col = 0; col < iS; col++) { ColCheckVar = SNum[col][row]; // assigns the value in SNum[x][y] to the check Variable IsValid_Col(SNum, iS, NumOfDoubles_Col, ColCheckVar, row, col); } } SetCursorPosition(0, 25); std::cout << " No.Doubles: " << NumOfDoubles_Col << std::endl; // only here for testing purposes if(NumOfDoubles_Col != 0) return true; // i realize i probably dont need to have this in here as IsValid returns a boolean but ill fix that later else return false; } bool IsValid_Col(int SNum[][9], int iS, int &NumOfDoubles_Col, int ColCheckVar, int row, int col) { for(int n = 1; n < iS - 1; n++) { // n is used to iterate over the numbers in a col eg. col = 0, 0 + 1, 0 + 2, 0 + 3. etc. if(ColCheckVar == SNum[col + n][row] && ColCheckVar != 0) NumOfDoubles_Col++; // if check variable is equal to number at SNum[x][y] and the variable is not equal to 0 then add 1 to the number of doubles } if(NumOfDoubles_Col == 0) return true; // returns true if there are no doubles in the columns else return false else return false; }

i have been stuck on this for about a week and its the last thing i need to do for the sudoku program i have tried to find a solution on my own but i just cant figure it out />

any help would be greatly appreciated.

This post has been edited by **Shadow-coder**: 17 July 2015 - 08:53 PM