It is a test

扫雷

https://ac.nowcoder.com/acm/problem/22232?&headNav=acm

just for test.我相信只有像我这样的傻子才会发这种题

#include<bits/stdc++.h>
using namespace std;
bool a[101][101];
int m,n;
int main(){
     cin>>m>>n;
    for(int i=1;i<=m;++i){
             for(int j=1;j<=n;++j){
                 char x;
                 cin>>x;
                 if(x=='*')a[i][j]=true;
             }
        getchar();
    }
    for(int i=1;i<=m;++i){
             for(int j=1;j<=n;++j){
                 int sum=0;
                 if(a[i][j]) cout<<'*';
                 else{
                    for(int dx=-1;dx<=1;dx++){
                        for(int dy=-1;dy<=1;dy++){
                            if(a[i+dx][j+dy])sum++;
                        }
                    }
                     cout<<sum;
                 }
             }
        cout<<'\n';
    }
}
全部评论

相关推荐

牛客92804383...:在他心里你已经是他的员工了
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务