70pts求助!
查看原帖
70pts求助!
1126670
cysxc11111楼主2023/10/29 10:36

rt

#include<bits/stdc++.h>
using namespace std;
int a[101][101];
char b[101][101];
int main(){
    int heng,shu;
    cin>>heng>>shu;
    for(int i=0;i<=heng;i++){
        for(int j=0;j<=shu;j++){
            a[i][j]=0;
        }
    }
    for(int i=1;i<=heng;i++){
        for(int j=1;j<=shu;j++){
            cin>>b[i][j];
        }
    }
    for(int i=1;i<=heng;i++){
        for(int j=1;j<=shu;j++){
            if(b[i][j]=='*') a[i][j]=1;
        }
    }
    for(int i=1;i<=heng;i++){
        for(int j=1;j<=shu;j++){
            if(b[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<<"*";
        }
        cout<<endl;
    }
    return 0;
}
2023/10/29 10:36
加载中...