the 21st tijie
2023-12-27 20:13:09
发布于:广东
2阅读
0回复
0点赞
题解
#include <iostream>****加粗文本****
#include <stdio.h>
using namespace std;
const int maxn = 110;
int main(){
char a[110][110];
int sum[100][100] = {0};
int n, m;
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i++){
scanf("%s", &a[i]);
getchar();
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(a[i][j] == '*'){
sum[i][j] = -1;
continue;
}
if(a[i - 1][j - 1] == '*'){
sum[i][j]++;
}
if(a[i - 1][j] == '*'){
sum[i][j]++;
}
if(a[i - 1][j + 1] == '*'){
sum[i][j]++;
}
if(a[i][j - 1] == '*'){
sum[i][j]++;
}
if(a[i][j + 1] == '*'){
sum[i][j]++;
}
if(a[i + 1][j - 1] == '*'){
sum[i][j]++;
}
if(a[i + 1][j] == '*'){
sum[i][j]++;
}
if(a[i + 1][j + 1] == '*'){
sum[i][j]++;
}
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(sum[i][j] != -1){
printf("%d", sum[i][j]);
}else{
putchar('*');
}
}
putchar('\n');
}
return 0;
}
以下非题解
#include <iostream>
using namespace std;
int main(){
cout << "subcribe~~";
return 0;
}
这里空空如也
有帮助,赞一个