C语言 N皇后问题 详解
我是JaYLove0589。
望大家指正。
题目描述
在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。
你的任务是,对于给定的N,求出有多少种合法的放置方法。
输入
共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。
输出
共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。
样例输入
1
8
5
0
样例输出
1
92
10
Here are my code:
//
// T2 N皇后问题.c
// c 191219
//
// Copyright © 2019 JaYLove0589. All rights reserved.
//
#include <stdio.h>
#include <string.h>
int getMethod(const int n);
int checkPoint(int *column,const int n);
int main(){
const int MAX=10;//说明N最大为10
const int END=0;//说明输入0表示程序结束
int N;
while (scanf("%d",&N)