Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 25th, 2006, 1:29 PM   #1
nascar2000
Newbie
 
Join Date: Apr 2006
Posts: 9
Rep Power: 0 nascar2000 is on a distinguished road
sudoku help needed

i coded a sudoku program ,but i am having a problem with it. my sudoku can find whether row/col/and 3*3 duplicate numbers(uses isLegal() function). grid is generated by random numbers .these random numbers will go into empty grids in the square. if duplicate numbers exists(isLegal function becomes false) i make the current square empty. after that i want to count other numbers and check whether its valid or not, if valid it will go to the empty squares.any help is appreciated..

code-------------------------------------------------------------------
bool generation(int newGrid[9][9],int r,int c) //generation function with arg
{
if(c == 9)
{
if(++r == 9)
return true;
c = 0;
}
if(newGrid[r][c] != 0)
return generation(newGrid, r, c + 1);
do
{
const int randV = (rand() % 9) + 1;
newGrid[r][c] = randV;
if(!isLegal())
{
newGrid[r][c] = 0;
return false;
}
}
while(!generation(newGrid, r, c + 1));

return true;


}
nascar2000 is offline   Reply With Quote
Old Apr 25th, 2006, 1:49 PM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
You might wish to read the "How to post a question" thread at the top of the forum.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC