⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8huanghou.txt

📁 八皇后问题
💻 TXT
字号:
#include<iostream>
using namespace std;
const int o=8;
int q[o][o];
int r[o];
int main(){
int t3=o-1;
int z=1;


	for( r[0]=0;r[0]<=t3;++r[0])
    for( r[1]=0;r[1]<=t3;++r[1])
	for( r[2]=0;r[2]<=t3;++r[2])
	for( r[3]=0;r[3]<=t3;++r[3])
		for( r[4]=0;r[4]<=t3;++r[4])
			for( r[5]=0;r[5]<=t3;++r[5])
				for( r[6]=0;r[6]<=t3;++r[6])
					for( r[7]=0;r[7]<=t3;++r[7])
	
	
	
	
	{
		for(int s=0;s<=t3;++s){
		q[s][r[s]]=1;
	    }
       







int shu1=0,shu2=2;
for(int m=0;m<=t3;++m){
	shu1=0;
	for(int op=0;op<=t3;++op)
	{shu1=shu1+q[op][m];}
if(shu1>=2)
       ++shu2;

}
int w1=0,w2=0,w3=0,w4=0,z1=0,z2=0,z3=0;
for(int x=0;x<=t3;++x){
	w1=0,w2=0,w3=0,w4=0,z1=x,z2=t3-x,z3=x+t3;

for(int y=0;y<=t3;++y){
	if(z1<=t3 && y<=t3){
		w1=w1+q[z1][y];}
	
	if(z1<=t3 && y<=t3){
	  w2=w2+q[y][z1];
	}
	z1=z1+1;
	if(z2>=0 && y<=t3){
		w3=w3+q[y][z2];
		}
	z2=z2-1;
	if(z3<=t3 && y<=t3){
	    w4=w4+q[y][z3];
	}
    z3=z3-1;
if(w1>=2)
++shu2;
if(w2>=2)
++shu2;
if(w3>=2)
++shu2;
if(w4>=2)
++shu2;
}
}
	if(shu2<=2)
	{
	
	for(int i=0;i<=t3;++i){
		for(int j=0;j<=t3;++j)
			cout<<q[i][j]<<" " ;
			cout<<endl;
	}
	cout<<endl<<z<<endl;
	z=z+1;
	}
	 	for(int s2=0;s2<=t3;++s2){
		q[s2][r[s2]]=0;
	    }
}
}

⌨️ 快捷键说明

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