poj2612Mine Sweeper
很简单的模拟题目,但在队内赛的时候一直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的更多相关文章
- poj 2612 Mine Sweeper
Mine Sweeper Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6429 Accepted: 2500 Desc ...
- 2020杭电多校 10C / HDU 6879 - Mine Sweeper (构造)
HDU 6879 - Mine Sweeper 题意 定义<扫雷>游戏的地图中每个空白格子的值为其周围八个格子内地雷的数量(即游戏内临近地雷数量的提示) 则一张地图的值\(S\)为所有空白 ...
- 2020杭电多校 C / HDU 6879 - Mine Sweeper
题意: t组输入,每组输入一个s 你需要输出一个r行c列的阵列,这个阵列中'X'代表炸弹,'.'表示没有炸弹 对于'.'这些位置都会有一个数值,这个值取决于这个位置附近8个位置,这8个位置一共有几个炸 ...
- 多级弹出菜单jQuery插件ZoneMenu
ZoneMenu是一个菜单jQuery插件,只需占用页面上的一个小区域,却可以实现多级菜单. 在线体验:http://keleyi.com/jq/zonemenu/ 点击这里下载 完整HTML文件代码 ...
- golang内存分配
golang内存分配 new一个对象的时候,入口函数是malloc.go中的newobject函数 func newobject(typ *_type) unsafe.Pointer { flags ...
- Greenplum 集群部署
最近开始接触Greenplum,线上也在使用了,感觉还不错,本次介绍一下集群的部署方法.那么Greenplum的架构如下: (架构图来源网络) 简单来说GPDB是一个分布式数据库软件,其可以管理和处理 ...
- Greenplum 在Linux下的安装
1.实验环境 1.1.硬件环境 Oracle VM VirtualBox虚拟机软件:三台Linux虚拟机:Centos 6.5:数据库:greenplum-db-4.3.9.1-build-1-rhe ...
- Metasploit辅助模块
msf > show auxiliary Auxiliary ========= Name Di ...
- 全情投入是做好工作的基础——Leo鉴书39
很多人都有:“内向的人则不擅长社交,只能会活得很封闭”的思想,于是不少内向的朋友要么认为只有扭曲自己的性格变得外向才能在社会上吃得开,才能很爽的行走职场:要么就决定完全封闭自己活在孤独之中,其实以上两 ...
随机推荐
- innodb之超时参数配置
可参考:http://www.penglixun.com/tech/database/mysql_timeout.html 下面内容摘取自上面这个链接. connection_timeout,只是设置 ...
- Android Service 与 IntentService
Service 中的耗时操作必须 在 Thread中进行: IntentService 则直接在 onHandleIntent()方法中进行
- Linux内存性能指标、CPU性能指标
内存性能指标 内存基础概念 先执行一下 top 命令,看结果中关于内存的相关部分 # top 其中的 VIRT.RES.SWAP 都是什么呢? 分别是下面的3个概念: 物理内存 Resident - ...
- C# 设计模式 提高可维护性的几点原则
为了提高软件的可维护性,应该遵循以下几点原则: 1.“开放--封闭”原则(OCP) 一个软件实体应该对扩展开放,对修改封闭. 2.里氏代换原则(LSP) 子类型必须能替换她们的基类型,反过来则不成立. ...
- Java代码实现excel数据导入到Oracle
1.首先需要两个jar包jxl.jar,ojdbc.jar(注意版本,版本不合适会报版本错误)2.代码: Java代码 import java.io.File; import java.io.Fi ...
- bootstrap组件 2
bootstrap组件2 <!DOCTYPE html> <html lang="zh-cn"> <head > <meta charse ...
- C# 与 Microsoft Expression Encoder实现屏幕录制
在日常开发中,我们会经常遇到屏幕录制的需求.在C#中可以通过Expression Encoder的SDK实现这样的需求.首先需要下载Expression Encoder SDK,实现代码: priva ...
- 【leetcode】Candy
题目描述: There are N children standing in a line. Each child is assigned a rating value. You are giving ...
- [Eclipse] Eclipse配置Tomcat插件
1 . Eclipse IDE 3.6 for Java EE Developersat- 5.5.28 或者以上版本 : 2 . 安装 Tomcat 插件 , 文件名: tomcatPluginV3 ...
- 发送http请求get方法
//获取网页html NSURL* url = [NSURL URLWithString:@"http://www.baidu.com"]; NSMutableURLRequest ...