#include<stdio.h>
int a[15];
int tot=0;
int main()
{
void search(int x);
search(0);
printf("%d\n",tot);
return 0;
}
void search(int x)
{
if(x==8)
tot++;
else
{
int i,j;
for(i=0;i<8;i++)
{
a[x]=i;
for(j=0;j<x;j++)
if(a[j]==a[x]||a[j]-j==a[x]-x||j+a[j]==x+a[x])
break;
if(j==x)
search(x+1);
}
}
}八皇后 入门经典
转载文章标签 i++ #include 文章分类 JavaScript 前端开发
-
经典问题“八皇后”的解法
经典问题“八皇后”的经典解法
C语言 八皇后 回溯算法 -
经典算法问题:八皇后的Python解法
想了想,没啥说的,代码不算难,涉及到的知识点本文都有说明:#八皇后问题board=[ [0,0
Python range enumerate 八皇后问题 python -
【LeetCode】八皇后
递归经典题
leetcode 算法 深度优先 深搜 -
【C/C++ 学习】mutable关键字
mutable关键字学习记录
#c语言 #c++ #学习 成员变量 #include
















