为什么不输出?
#include <bits/stdc++.h>
using namespace std;
int a,b,c[7][7];
bool vis[17];
void dfs(int x,int y)
{
if(x==a&&y==b){
c[x][y]=1;
if(y==4)
dfs(x+1,1);
else
dfs(x,y+1);
}
if(x==5&&y==1){
if(c[1][1]+c[2][2]+c[3][3]+c[4][4]!=34)
return;
if(c[1][4]+c[2][4]+c[3][4]+c[4][4]!=34)
return;
if(c[4][1]+c[4][2]+c[4][3]+c[4][4]!=34)
return;
if(c[1][1]+c[1][4]+c[4][1]+c[4][4]!=34)
return;
if(c[3][3]+c[3][4]+c[4][3]+c[4][4]!=34)
return;
for(int i=1;i<=4;i++){
for(int j=1;j<=4;j++)
cout << c[i][j];
cout << endl;
}
return;
}
if(x==2&&y==3){
if(c[1][1]+c[1][2]+c[2][1]+c[2][2]!=34)
return;
}
if(x==3&&y==1){
if(c[1][3]+c[1][4]+c[2][3]+c[2][4]!=34)
return;
}
if(x==4&&y==3){
if(c[3][1]+c[3][2]+c[4][1]+c[4][2]!=34)
return;
}
for(int i=2;i<=4;i++){
if(x==i&&y==1){
if(c[i-1][1]+c[i-1][2]+c[i-1][3]+c[i-1][4]!=34)
return;
}
}
for(int i=2;i<=4;i++){
if(x==4&&y==i){
if(c[1][i-1]+c[2][i-1]+c[3][i-1]+c[4][i-1]!=34)
return;
}
}
if(x==3&&y==4){
if(c[2][2]+c[2][3]+c[3][2]+c[3][3]!=34)
return;
}
if(x==4&&y==2){
if(c[1][4]+c[2][3]+c[3][2]+c[4][1]!=34)
return;
}
for(int i=1;i<=16;i++){
if(vis[i])
continue;
c[x][y]=i;
vis[i]=1;
return;
if(y==4)
dfs(x+1,1);
else
dfs(x,y+1);
vis[i]=0;
}
}
int main()
{
cin >> a >> b;
for(int i=1;i<=16;i++) vis[i]=0;a
c[a][b]=1;
vis[1]=1;
dfs(1,1);
return 0;
}
求助