编译失败
/tmp/compiler_z4v843n9/src: 在函数‘void dfs(int, int, int)’中:
/tmp/compiler_z4v843n9/src:16:71: 错误:ISO C++ 不允许比较指针和整数的值 [-fpermissive]
16 | if(x + dx[i] > 0 && x + dx[i] <= n && y + dy[i] > 0 && y + dy <= m && (Map[x + dx[i]][y + dy[i]] == -1 || Map[x + dx[i]][y + dy[i]] > step + 1))
| ^
#include<bits/stdc++.h>
using namespace std;
int dx[] = {2,1,-1,-1,-1,-2,2,1},
dy[] = {1,2,-2,-2,2,1,-1,-2};
int Map[403][403];
int n, m, x, y;
struct node{
int x, y;
};
void dfs(int x,int y,int step)
{
if(step>=201)
return;
Map[x][y] = step;
for(int i = 0; i < 8; i++){
if(x + dx[i] > 0 && x + dx[i] <= n && y + dy[i] > 0 && y + dy <= m && (Map[x + dx[i]][y + dy[i]] == -1 || Map[x + dx[i]][y + dy[i]] > step + 1))
dfs(x + dx[i], y + dy[i], step + 1);
}
}
int main(){
cin>>n>>m>>x>>y;
memset(Map,-1,sizeof(Map));
dfs(x,y,0);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
cout<<left<<setw(5)<<Map[i][j];
cout<<endl;
}
}