过河卒求调
  • 板块灌水区
  • 楼主franxx112
  • 当前回复4
  • 已保存回复4
  • 发布时间2022/10/9 20:00
  • 上次更新2023/10/27 08:04:03
查看原帖
过河卒求调
630442
franxx112楼主2022/10/9 20:00

过河卒五个对了三个 求大佬们帮忙看看谢谢啦

#include<iostream>
#include<cstring>
using namespace std;
int a,b,c,d;
long long q[25][25];
bool f(int x,int y){
	if(x==a-1&&y==b-2)return 0;
	if(x==a-2&&y==b-1)return 0;
	if(x==a-1&&y==b+2)return 0;
	if(x==a-2&&y==b+1)return 0;
	if(x==a+1&&y==b-2)return 0;
	if(x==a+2&&y==b-1)return 0;
	if(x==a+1&&y==b+2)return 0;
	if(x==a+2&&y==b+1)return 0;
    if(x==a&&y==b)return 0;
	return 1;
}
int main(){
	cin>>c>>d>>b>>a;
    for(int i=0;i<=c;i++){
        for(int j=0;j<=d;j++){
            if(f(i,j))
            {
                q[i][j]=f(i,j);
            }cout<<q[i][j]<<" ";
        }
        cout<<endl;
    }
    for(int i=1;i<=c;i++){
        for(int j=1;j<=d;j++){
            if(f(i,j))
            {
                q[i][j]=q[i-1][j]+q[i][j-1];
                
            }cout<<q[i][j]<<" ";
        }
        cout<<endl;
    }
	cout<<q[c][d];
	return 0;
} 
2022/10/9 20:00
加载中...