P2670 扫雷游戏

 地址:https://www.luogu.com.cn/problem/P2670

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

 

上一篇:题解 P5930[POI1999] 降水


下一篇:Oil Deposits