RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 1243 | Replies: 1
Reply
Join Date: Apr 2007
Posts: 5
Reputation: emr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
emr emr is offline Offline
Newbie Poster

how can i solve Queen problem please help me

  #1  
May 12th, 2007
i have a homework
my homework is to place 8 quenns pieces from the game of chess
on a chessboard so that no queen piece is threatening another queen on the board.All of the solutions can be found using a recursive algorithm.The algorithm works by placing queens on various positions,adding one queen at a time until either eight queens have been placed on the chess board or less than eight queens are on the board but there are no more safe positions left on the board.When the latter situation is reached the algorithm backtracks and tries another layout of queen.
that is my homework
i thought declaring an array like that int a[8][8] and put 2 for queen and put 1 to threatining place into this array
i wrote the function that puts 1 for threatining place after putting the queen the function is this
int fill(int i,int j){
int a[8][8];
while(i<8){
i++;
a[i][j]=1;
}
while(i>=0){
i--;
a[i][j]=1;
}
while(j<8){
j++;
a[i][j]=1;
}
while(j>=0){
j--;
a[i][j]=1;
}
while(i<8&&j<8){
i++;j++;
a[i][j]=1;
}
while(i>=0&&j>=0){
i--;j--;
a[i][j]=1;}}

but the problem is putting the queens with a recursive function
how can i put the queens with a recursive function
please help me
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: how can i solve Queen problem please help me

  #2  
May 12th, 2007
Your question will be answer shortly. In the meanwhile please do
read this short guide on how to tag your code properly.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

Thread Tools Display Modes
All times are GMT -4. The time now is 2:01 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC