Don't understand a function in this sudoku solver

http://rapidshare.com/files/lain.cpp.html

I understand everything what the solver does but I do not understand what the guess_number() function is doing in the code.
Would someone please explain me how the guess_number() is working ?

Thanks for reading,
G'day

P.S. - I am giving the rapidshare link because I am getting the error : Field "Content" too long: max is 9000 characters
Last edited on
Can you please post just that function?
I would post the function man, but trust me, it'd not make any point if you didn't know what arguments were passed from the main function to that function...
...
Last edited on
.
Last edited on
.
Last edited on
Last edited on
Is this what you're stumbling on?

1
2
3
4
5
6
7
8
9
if(num++==10)
	{
		num=1;
		if(col++==9)
		{
			col=0;
			row++;
		}
	}


++== is testing if the number is equal to something, and adding one to it after the conditional test... so if it is 10 it will be reset to 1, otherwise 1 is just added... same thing is happening on your column... its basically advancing the number and the column if such an action is applicable to the situation.
The rest of that function has pretty obvious comments...
BTW I didn't even read the rest of the program, I could have told you that much just seeing the function.

Another way of coding it would be:

1
2
3
num++;
if(num == 11)
   num = 1; //etc. 
Last edited on
Thank you Malachi, but unfortunately that wasn't it.
The problem is with the logic, I do not get the logic of the work that the function performs...
Topic archived. No new replies allowed.