我们使用dfs的时候,要想好递归的终止条件怎么写。这是最重要的
#include <bits/stdc++.h>
using namespace std;
const int N=100;
int a[N][N];
bool col[N];
bool add[N];
bool sub[N];
int n;
void dfs(int row)
{
if(row==n+1)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j])
{
printf("Q");
}
else
{
printf(".");
}
}
printf("\n");
}
printf("\n");
return ;
}
for(int i=1;i<=n;i&