20求助
查看原帖
20求助
583833
LubsWangKillThemAll楼主2023/2/22 22:01
#include<iostream> 
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int N=1005;

int main(){
	int n,m;
	int shape1[102][102];
	char shape2[102][102];
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			shape1[i][j]=0;
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>shape2[i][j];
			if(shape2[i][j]=='*'){//start |if|
				shape1[i+1][j+1]++;
				shape1[i][j+1]++;
				shape1[i-1][j+1]++;
				shape1[i+1][j]++;
				//shape1[i][j];
				shape1[i-1][j]++;
				shape1[i+1][j-1]++;
				shape1[i][j-1]++;
				shape1[i-1][j-1]++;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(shape2[i][j]=='*'){
				cout<<"*";
			}else{
				cout<<shape1[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}
}

<fontsize=1000>20求助</font><font size=1000>20求助</font>

2023/2/22 22:01
加载中...