EightQueens in the game of chess
来源:互联网 发布:刘晓庆入狱知乎 编辑:程序博客网 时间:2024/06/04 20:06
国际象棋八皇后相容排阵问题:
My code of today
#include <iostream.h>
//八皇后求解
int k=0,result[10]={0};
int main()
{
void search();
void shresult();
search();
return(0);
}
//Show the result
void shresult()
{
for(k=0;k<8;k++) cout<<result[k]<<',';
cout<<"/t OK"<<endl;
}
//Searching the answer for the problem.
void search()
{
int i,j,judge;
for(i=0;i<8;i++)
{
judge=1;
for(j=0;j<k;j++)
{
if(i==result[j]) judge&=0;
if(i==(result[j]-k+j)) judge&=0;
if(i==(result[j]+k-j)) judge&=0;
}
if(judge){result[k]=i;k++;search();}
}
if(!(k<8)) shresult();
k--;
}
- EightQueens in the game of chess
- The Use of Design Patterns In Game Development
- The rule of game
- Game of the Rows
- Game of the Rows
- Game of Life in Haskell
- Secrets of the Game Business
- The Game of 31 (博弈)
- hdu4155 The Game of 31
- soj1171 The Game of Efil
- Codeforces549C - The Game Of Parity
- The Game of iGameGuardian7.3.1
- cf839B Game of the rows
- Codeforces839B Game of the Rows
- Game of the Rows CodeForces
- Game of the Rows CodeForces
- CodeForces839B Game of the Rows
- daily_journal_3 the game of thrones
- 如何学习JAVA??(只对JAVA初学者)
- WSAEventSelect模型
- C++学习笔记一 —— 3.5 const限定修饰符
- 使用SQL-DMO实现定制SQLScripts
- 演练VC中的COMMON一族(转贴)之一
- EightQueens in the game of chess
- makefile中defien something的办法
- DBA的最佳选择—图形界面还是T-SQL命令?
- 让语言选择即时生效
- 演练VC中的COMMON一族(转贴)之二
- JS更改onclick事件
- 先排序还是先取值
- 演练VC中的COMMON一族(转贴)之三
- 用C语言写PHP扩展的步骤