很简单的模拟题目,但在队内赛的时候一直WA了10发。。。我ca

题目没看懂,也不算,就是我以为摸到地雷他会标星(*) ,但其实还是(x),T_T

 #include <cstdio>
#include <iostream>
#include <cstring>
using namespace std; int n;
bool tag = false;
char graph1[][];
char graph2[][];
char graph3[][]; int mov[][] = {{-, -}, {-, }, {-, }, {, -}, {, }, {, -}, {, }, {, }}; bool check(int x, int y)
{
if(x >= && y >= && x < n && y < n)
return true;
return false;
} int handle(int i, int j)
{
int sum = ;
for(int k = ; k < ; ++k)
{
int x = mov[k][] + i;
int y = mov[k][] + j;
if(check(x, y) && graph1[x][y] == '*')
{
sum++;
}
}
return sum;
} int main()
{ int i, j;
while(scanf("%d%*c", &n) != EOF)
{
memset(graph1, , sizeof(graph1));
memset(graph2, , sizeof(graph2));
memset(graph3, , sizeof(graph3)); for(i = ; i < n; ++i)
{
gets(graph1[i]);
//puts(graph1[i]);
}
for(i = ; i < n; ++i)
{
gets(graph2[i]);
//puts(graph2[i]);
} for(i = ; i < n; ++i)
{
for(j = ; j < n; ++j)
{
if(graph2[i][j] == 'x' && graph1[i][j] == '*')
tag = true;
}
} if(tag == false)
{
for(i = ; i < n; ++i)
{
for(j = ; j < n; ++j)
{
if(graph2[i][j] == 'x')
{
graph3[i][j] = '' + handle(i, j);
}
else
{
graph3[i][j] = '.';
}
}
}
}
else
{
for(i = ; i < n; ++i)
{
for(j = ; j < n; ++j)
{
if(graph1[i][j] != '*' && graph2[i][j] == 'x')
{
graph3[i][j] = '' + handle(i, j);
}
else if(graph2[i][j] == '.' && graph1[i][j] == '*')
{
graph3[i][j] = '*';
}
else if(graph2[i][j] == 'x' && graph1[i][j] == '*')
{
graph3[i][j] = '*';
}
else
{
graph3[i][j] = '.';
}
}
}
} for(i = ; i < n; ++i)
{
puts(graph3[i]);
}
}
return ;
}

poj2612Mine Sweeper的更多相关文章

  1. poj 2612 Mine Sweeper

    Mine Sweeper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6429   Accepted: 2500 Desc ...

  2. 2020杭电多校 10C / HDU 6879 - Mine Sweeper (构造)

    HDU 6879 - Mine Sweeper 题意 定义<扫雷>游戏的地图中每个空白格子的值为其周围八个格子内地雷的数量(即游戏内临近地雷数量的提示) 则一张地图的值\(S\)为所有空白 ...

  3. 2020杭电多校 C / HDU 6879 - Mine Sweeper

    题意: t组输入,每组输入一个s 你需要输出一个r行c列的阵列,这个阵列中'X'代表炸弹,'.'表示没有炸弹 对于'.'这些位置都会有一个数值,这个值取决于这个位置附近8个位置,这8个位置一共有几个炸 ...

  4. 多级弹出菜单jQuery插件ZoneMenu

    ZoneMenu是一个菜单jQuery插件,只需占用页面上的一个小区域,却可以实现多级菜单. 在线体验:http://keleyi.com/jq/zonemenu/ 点击这里下载 完整HTML文件代码 ...

  5. golang内存分配

    golang内存分配 new一个对象的时候,入口函数是malloc.go中的newobject函数 func newobject(typ *_type) unsafe.Pointer { flags ...

  6. Greenplum 集群部署

    最近开始接触Greenplum,线上也在使用了,感觉还不错,本次介绍一下集群的部署方法.那么Greenplum的架构如下: (架构图来源网络) 简单来说GPDB是一个分布式数据库软件,其可以管理和处理 ...

  7. Greenplum 在Linux下的安装

    1.实验环境 1.1.硬件环境 Oracle VM VirtualBox虚拟机软件:三台Linux虚拟机:Centos 6.5:数据库:greenplum-db-4.3.9.1-build-1-rhe ...

  8. Metasploit辅助模块

    msf > show auxiliary Auxiliary ========= Name                                                  Di ...

  9. 全情投入是做好工作的基础——Leo鉴书39

    很多人都有:“内向的人则不擅长社交,只能会活得很封闭”的思想,于是不少内向的朋友要么认为只有扭曲自己的性格变得外向才能在社会上吃得开,才能很爽的行走职场:要么就决定完全封闭自己活在孤独之中,其实以上两 ...

随机推荐

  1. 三、jQuery--jQuery基础--jQuery基础课程--第8章 jQuery 实现Ajax应用

    1.使用load()方法异步请求数据 使用load()方法通过Ajax请求加载服务器中的数据,并把返回的数据放置到指定的元素中,它的调用格式为:load(url,[data],[callback]) ...

  2. CLR via C#学习笔记----知识总概括

    第1章 CLR的执行模型 托管模块的各个组成部分:PE32或PE32+头,CLR头,元数据,IL(中间语言)代码. 高级语言通常只公开了CLR的所有功能的一个子集.然而,IL汇编语言允许开发人员访问C ...

  3. 微信支付 - V3支付问题

    参考资料:http://www.2cto.com/weixin/201506/407690.html   1.微信公众号支付出错: 当前页面的URL未注册: get_brand_wcpay_reque ...

  4. Android OkHttp完全解析 --zz

    参考文章 https://github.com/square/okhttp http://square.github.io/okhttp/ 泡网OkHttp使用教程 Android OkHttp完全解 ...

  5. MVC授权认证

    处于安全性考虑,MVC可以完成授权认证,授权认证的方式如下: 1.配置Config文件,设置登录页面: <authentication mode="Forms"> &l ...

  6. 【翻译十六】java-固定对象的定义方法

    A Strategy for Defining Immutable Objects The following rules define a simple strategy for creating ...

  7. OCJP(1Z0-851) 模拟题分析(二)over

    Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...

  8. supervisor使用

    supervisor是一个C/S系统,它可以在类unix操作系统让用户来监视和控制后台服务进程的数量,一个很重要的功能就是监控服务器的主要后台进程,并在出现问题是自动重启. 根据服务器上的python ...

  9. php 接受处理二进制数据流并保存成图片

    <form action="提交到处理地址" method="post" enctype="multipart/form-data" ...

  10. 老生常谈,正确使用memset

    转自:http://blog.csdn.net/my_business/article/details/40537653 前段项目中发现一个问题,程序总是在某个dynamic_cast进行动态转换时出 ...