全部评论 1

  • 本来就要很长

    #include <iostream>
    using namespace std;
    char a [105][105];
    int b[105][105];
    int x[10] = {-1,-1,-1,0,0,1,1,1};
    int y[10] = {-1,0,1,-1,1,-1,0,1};
    int main(){
        int n , m;
        cin >> n >> m;
        for(int i = 1 ;i <= n; i++){
            for(int j = 1; j<=m;j++){
                cin >> a[i][j];
                if(a[i][j] == '*'){
                    for(int k = 0; k <= 7; k++){
                        b[i + x[k]][j + y[k]]++;
                    }
                }
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m ; j++){
                if(a[i][j]=='*')cout << "*";
                else cout << b[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    

    2024-07-23 来自 浙江

    0
首页