know the personalities
hold your mouse,move left and right

NQUEEN PROBLEM


job detailsFree Publishing of valuable information(s) in our website-Procedure to submit detailsjob details

Free Publishing of your College/University function details


Free Publishing of Your College/University function details in our website.Please send details to following email ids


technicalsymposium@gmail.com.
technicalsymposium@in.com.
technicalsymposium@yahoo.com.
technicalsymposium@hotmail.com.
Google Groups

Get Free E-Mail Alerts Daily

Get Daily Job/EntranceExam/Scholarships/
Admission/Competitive Exam Details Symposium/Conference Alerts in your email

Please Enter your email id and go to your inbox and confirm.You will be a member in our group.

Email:
Visit this group

Freshers Jobs/Symposium/Conference/Certification &Education News Given Below-Get Now

Freshers Jobs and IT /Govt Jobs

Symposium and Conference Details

Free Lecture Notes

Free Placement Papers

Free Project Codings


                

NQUEEN PROBLEM
#include<stdio.h>
void main()
{
int i,k=0,n,row[15],ddiag[20],udiag[20];
int board[15],r,j;
clrscr();
printf("\n\t\tN QUEEN'S PROBLEM\n\n");
printf("\n\tEnter the No. of Queens to be placed : ");
scanf("%d",&n);
for(i=0;i<n;i++)
board[i]=row[i]=0;
for(i=0;i<(2*n);i++)
ddiag[i]=udiag[i]=0;
while(1)
{
r=board[k];
if(!row[r] && !ddiag[n-1-k+r] && !udiag[k+r])
{
row[r]=ddiag[n-1-k+r]=udiag[k+r]=1;
k++;
if(k==n)
{
printf("\n\n\t\tSOLUTION\n\n ");
for(i=0;i<n;i++,printf("\n\n "))
for(j=0;j<n;j++,printf(" "))
if(j==board[i])
printf("Q");
else
printf("-");
getch();
exit(0);
}
else
board[k]=0;
}
else
{
board[k]++;
while(board[k]==n)
{
k--;
row[board[k]]=0;
ddiag[n-1-k+board[k]]=0;
udiag[k+board[k]]=0;
board[k]++;
}
}
}
}

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com