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';
    }
}
全部评论

相关推荐

04-21 11:22
已编辑
中华女子学院 UE4
耐心学习_佩可officical:直接举报他,佬,违反劳动法我记得boss会下架
点赞 评论 收藏
分享
04-18 15:58
已编辑
门头沟学院 设计
kaoyu:这一看就不是计算机的,怎么还有个排斥洗碗?
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务