八皇后问题
来源:互联网 发布:mysql的insert语句 编辑:程序博客网 时间:2024/06/06 13:06
#include<cstdio>int n,a[8],counts,map[8][8];void print(int x){if(x==n){++counts;printf("%d\n",counts);for(int i=0;i<n;++i){for(int j=0;j<n;++j)printf("%d ",map[i][j]);putchar('\n');}puts("---------------------------------");return;}for(int i=0;i<n;++i){a[x]=i;int ok=1;for(int j=0;j<x;++j){if((a[x]==a[j])||(a[x]+x==j+a[j])||(j-a[j]==x-a[x])){ok=0;break;}}if(ok){map[x][i]=1;print(x+1);map[x][i]=0;}}}int main(){n=8;print(0);return 0;}
0 0
- 八皇后 n皇后 问题
- 八皇后N皇后问题
- 八皇后问题
- 八皇后问题
- 八皇后问题
- 八皇后问题(2)
- 八皇后问题(3)
- 八皇后问题
- 八皇后问题程序
- 浅谈八皇后问题
- 八皇后问题
- 八皇后问题
- 八皇后问题
- 八皇后问题
- 八皇后问题求解
- 八皇后问题
- 八皇后问题
- 八皇后问题
- Open Judge 2811 熄灯问题
- 这是一个新的开始
- python 遍历目录
- zookeeper perl 版本需求
- 树状DP
- 八皇后问题
- 提高项目39-电子词典
- jsp 报错The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- java IO
- CentOS修改hostname(主机名)
- KNN算法(邻近算法)
- LeetCode 35. Search Insert Position
- 221. Maximal Square
- regulator