queen.cpp

来自「一个硬件测试工具的源代码」· C++ 代码 · 共 39 行

CPP
39
字号
#include "queen.h"
#include <afxwin.h>



void CQueenApp::Versuch(int i)
{
	int j=1;
	int k=1;
	while (j<9)
	{
		if ((a[j])&&(b[i+j])&&(c[i-j+7]))
		{
			x[i]=j;
			a[j]=false; b[i+j]=false; c[i-j+7]=false;
			if (i<8) {Versuch(i+1);}
			a[j]=true;b[i+j]=true;c[i-j+7]=true;
		}
	++j;
	}
}

long CQueenApp::DoQueen(long wiederhole)
{
	long re=0;
	while (re<wiederhole)
	{
		int i=0;
		while (i<9) {a[i]=true;++i;}
		i=0;
		while (i<17) {b[i]=true;++i;}
		i=0;
		while (i<15) {c[i]=true;++i;}
		Versuch(1);
	++re;
	}
	return (1);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?