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
很多人都有:“内向的人则不擅长社交,只能会活得很封闭”的思想,于是不少内向的朋友要么认为只有扭曲自己的性格变得外向才能在社会上吃得开,才能很爽的行走职场:要么就决定完全封闭自己活在孤独之中,其实以上两 ...
随机推荐
- 55. Jump Game leetcode
55. Jump Game Total Accepted: 95819 Total Submissions: 330538 Difficulty: Medium Given an array of n ...
- DLog的使用
DLog本质上就是个宏替换.DLog具体代码如下: #ifdef DEBUG #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt) ...
- vsftp详细配置(转)
详细配置转载来自以下链接: http://yuanbin.blog.51cto.com/363003/108262 vsftp源码下载(vsftpd-3.0.2.tar.gz): http://dow ...
- Java -- 访问控制
原文:http://www.cnblogs.com/diyingyun/archive/2011/12/21/2295947.html 可见/访问性 在同一类中 同一包中 不同包中 同一包子类中 ...
- HTTP 请求头中的 X-Forwarded-For
https://imququ.com/post/x-forwarded-for-header-in-http.html
- Generic Access Profile
转自:https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile Assigned numbe ...
- 【翻译二】java--并发之进程与线程
Processes and Threads In concurrent programming, there are two basic units of execution: processes a ...
- html5 Canvas绘制图形入门详解
html5,这个应该就不需要多作介绍了,只要是开发人员应该都不会陌生.html5是「新兴」的网页技术标准,目前,除IE8及其以下版本的IE浏览器之外,几乎所有主流浏览器(FireFox.Chrome. ...
- 攻城狮在路上(壹) Hibernate(十二)--- Hibernate的检索策略
本文依旧以Customer类和Order类进行说明.一.引言: Hibernate检索Customer对象时立即检索与之关联的Order对象,这种检索策略为立即检索策略.立即检索策略存在两大不足: A ...
- 兼容所有浏览器的JS动态显示当前日期时间
<script type="text/javascript"> function show_cur_times(){ //获取当前日期 var date_time = ...