为什么错!!!求助大大大大……大佬难受 纠结 痛苦
查看原帖
为什么错!!!求助大大大大……大佬难受 纠结 痛苦
1073177
Peruere楼主2023/10/6 16:21
#include<iostream>
using namespace std;
int a[21][21];
bool b[21][21];
const int dx[8]={-2,-1,-2,-1,1,2,2,1};
const int dy[8]={-1,-2,1,2,-2,-1,1,2};
int main(){
    int n,m,x,y;
    cin>>n>>m;
    a[0][0]=0;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            b[i][j]=0;
    cin>>x>>y;
    b[x][y]=1;
    for(int t=0;t<8;t++){
    int c=x+dx[t];
    int d=y+dy[t];
    if(0<=c&&c<=n&&0<=d&&d<=m)
        b[c][d]=1;
}
     for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){   
            if(i!=0) a[i][j]+=a[i-1][j];
            if(j!=0) a[i][j]+=a[i][j-1];
            if(b[i][j]==1)a[i][j]=0;
    }
}
    cout<<a[n][m];
    return 0;
}
2023/10/6 16:21
加载中...