80pts!!!!!!!!!
查看原帖
80pts!!!!!!!!!
1124042
Alies_FP楼主2023/11/12 20:50
#include<iostream>
using namespace std;

int main(){
	int n,m;
	int s=0;
	cin >> n >> m;
	char c[n+2][m+2];
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			cin >> c[i][j];
		}//喂喂喂喂喂喂喂喂 
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			s=0;
			if(c[i][j]=='*'){
				cout << "*";
			}
			else{
				if(c[i-1][j-1] == '*') s++;
				if(c[i-1][j] == '*') s++;
				if(c[i-1][j+1] == '*') s++;
				if(c[i][j+1] == '*') s++;
				if(c[i+1][j+1] == '*') s++;
				if(c[i+1][j] == '*') s++;
				if(c[i+1][j-1] == '*') s++;
				if(c[i][j-1] == '*') s++;
				cout << s;
			}
		}
		cout << endl;
	}
	return 0;
} 
2023/11/12 20:50
加载中...