AC题解
2023-08-09 12:17:30
发布于:浙江
1阅读
0回复
0点赞
#include <iostream>
using namespace std;
/* a[n(i),m(j)]
a[0,0] a[0,1] a[0,2] a[0,3] a[0,4]...
a[1,0]
a[2,0
a[3,0]
a[4,0]
.
.
.
/
int main(){
int n ,m;
cin >> n >> m;
char a[105][105];
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(a[i][j] == ''){
cout << '';
}else{
int num = 0;
if(a[i+1][j] == ''){
num++;
}
if(a[i][j+1] == ''){
num++;
}
if(a[i-1][j] == ''){
num++;
}
if(a[i][j-1] == ''){
num++;
}
if(a[i+1][j+1] == ''){
num++;
}
if(a[i-1][j-1] == ''){
num++;
}
if(a[i+1][j-1] == ''){
num++;
}
if(a[i-1][j+1] == '*'){
num++;
}
cout << num;
}
}
cout << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个