p2607 30分求bug
查看原帖
p2607 30分求bug
1427312
chenaex楼主2024/10/5 16:24
#include<bits/stdc++.h>

using namespace std;

int main()
{

    int a,b;
    cin>>a>>b;
    char c[a][b];
    int n[a][b];
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            cin>>c[i][j];
        }
    }
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            n[i][j]=0;
            int x=0;
            
            if(c[i][j]=='*')
            {
                n[i][j]=9;   
                n[i+1][j]++;
                n[i+1][j+1]++;
                n[i+1][j-1]++;
                n[i][j+1]++;
                n[i][j-1]++;
                n[i-1][j]++;
                n[i-1][j-1]++;
                n[i-1][j+1]++;
            }
            

        }
    }
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<b;j++)
        {
            if(n[i][j]>=9)
            {
                cout<<'*';
            }
            else
            {
                cout<<n[i][j];
            }   
        }
        cout<<endl;
    }
    return 0;
}
2024/10/5 16:24
加载中...