求大神,代码是不是编号错了 感谢!!
查看原帖
求大神,代码是不是编号错了 感谢!!
444420
leoduo楼主2021/1/8 16:58
#include <bits/stdc++.h>
using namespace std;

int main(){
	int x,y,n,m;
	char a[16][16];
	int b[16][16]={0};
	cin>>n>>m>>x>>y;
	a[x][y]='*';
	a[x+2][y+1]='*';
	a[x+1][y+2]='*';
	a[x-1][y+2]='*';
	a[x-2][y+1]='*';
	a[x-2][y-1]='*';
	a[x-1][y-2]='*';
	a[x+1][y-2]='*';
	a[x+2][y-1]='*';
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]=='*'){
				b[i][j]=0;
			}
			else{
				b[i][j]=1;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<b[i][j]<<" ";
		}
		cout<<endl;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(b[i][j]!=0){
				b[i][j]=b[i-1][j]+b[i][j-1];
				cout<<b[i][j]<<" ";
			}
			else{
				cout<<0<<" ";
			}
		}
		cout<<endl;
	}
	cout<<b[n-1][m-1];
}
2021/1/8 16:58
加载中...