哈哈题解!
2026-09-23 19:18:23
发布于:浙江
8阅读
0回复
0点赞
#include<iostream>
using namespace std;
int main(){
ios::sync_with_stdio(false);
char a[400][400];
int n,m;
char x;
cin>>n>>m;
for(int i = 1;i<=399;i++){
for(int j = 1;j<=399;j++){
a[i][j]=0;
}
}
for(int i = 100;i<=n+99;i++){
for(int j = 100;j<=m+99;j++){
cin>>a[i][j];
}
}
for(int i = 100;i<=n+99;i++){
for(int j = 100;j<=m+99;j++){
if(a[i][j]=='?'){
cout<<(a[i-1][j-1]=='*')+(a[i-1][j]=='*')+(a[i-1][j+1]=='*')+(a[i][j-1]=='*')+(a[i][j+1]=='*')+(a[i+1][j-1]=='*')+(a[i+1][j]=='*')+(a[i+1][j+1]=='*');
}
else {
cout<<"*";
}
}
if(i!=n+99)cout<<"\n";
}
}
这里空空如也








有帮助,赞一个