FZU 1056 扫雷游戏【搜索】
Accept: 2584 Submit: 6790
Time Limit: 1000 mSec Memory Limit :
32768 KB
Problem Description
你的任务是在已知地雷出现位置的情况下,得到各个方块中的数据。
.... “*”表示有地雷
.*.. “.”表示无地雷
....
经过处理应得到
2210
1*10
1110
Input
表示有地雷,“.”表示无地雷。最后一组数据m=0,n=0表示输入结束,不需要处理。
Output
Sample Input
***
...
4 4
*...
....
.*..
....
0 0
Sample Output
232
*100
2210
1*10
1110
Source
FZUPC Warmup 2005
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<streambuf>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
#define ll long long
#define oo 10000000 int n,m,cnt;
char a[][];
bool check(int x,int y)
{
if(x>=&&x<=n&&y>=&&y<=m&&a[x][y]=='*')
return true;
return false;
} int main()
{
while(~scanf("%d%d",&n,&m),n&&m)
{
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
cin>>a[i][j];
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
if(a[i][j]=='*')
cout<<"*";
else if(a[i][j]=='.')
{
cnt=;
for (int k=i-;k<=i+;k++)//八个方向搜索
{
for (int p=j-;p<=j+;p++)
{
if (check(k,p)) //合法(不越界+搜到地雷)
{
cnt++; //每次在八方向搜到一个地雷 计数器+1
}
}
}
printf("%d",cnt);
}
}
printf("\n");//注意格式
}
printf("\n");
}
}
暴搜
FZU 1056 扫雷游戏【搜索】的更多相关文章
- FZU 1056 扫雷游戏
水题.统计一下周围有几个雷. #include<cstdio> #include<cstring> #include<cmath> #include<algo ...
- FZU OJ 1056 :扫雷游戏
Problem 1056 扫雷游戏 Accept: 2624 Submit: 6903Time Limit: 1000 mSec Memory Limit : 32768 KB Prob ...
- Leetcode之广度优先搜索(BFS)专题-529. 扫雷游戏(Minesweeper)
Leetcode之广度优先搜索(BFS)专题-529. 扫雷游戏(Minesweeper) BFS入门详解:Leetcode之广度优先搜索(BFS)专题-429. N叉树的层序遍历(N-ary Tre ...
- 【Android】自己动手做个扫雷游戏
1. 游戏规则 扫雷是玩法极其简单的小游戏,点击玩家认为不存在雷的区域,标记出全部地雷所在的区域,即可获得胜利.当点击不包含雷的块的时候,可能它底下存在一个数,也可能是一个空白块.当点击中有数字的块时 ...
- C# -- HttpWebRequest 和 HttpWebResponse 的使用 C#编写扫雷游戏 使用IIS调试ASP.NET网站程序 WCF入门教程 ASP.Net Core开发(踩坑)指南 ASP.Net Core Razor+AdminLTE 小试牛刀 webservice创建、部署和调用 .net接收post请求并把数据转为字典格式
C# -- HttpWebRequest 和 HttpWebResponse 的使用 C# -- HttpWebRequest 和 HttpWebResponse 的使用 结合使用HttpWebReq ...
- iOS 扫雷游戏
代码地址如下:http://www.demodashi.com/demo/11254.html 1.项目结构图 Viewcontroller:扫雷逻辑代码 LevelModel:扫雷难度选择代码 2. ...
- Leetcode 529.扫雷游戏
扫雷游戏 让我们一起来玩扫雷游戏! 给定一个代表游戏板的二维字符矩阵. 'M' 代表一个未挖出的地雷,'E' 代表一个未挖出的空方块,'B' 代表没有相邻(上,下,左,右,和所有4个对角线)地雷的已挖 ...
- 洛谷 P2670 扫雷游戏==Codevs 5129 扫雷游戏
题目描述 扫雷游戏是一款十分经典的单机小游戏.在n行m列的雷区中有一些格子含有地雷(称之为地雷格),其他格子不含地雷(称之为非地雷格).玩家翻开一个非地雷格时,该格将会出现一个数字——提示周围格子中有 ...
- 原生javascript扫雷游戏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- A1082 Read Number in Chinese (25)(25 分)
A1082 Read Number in Chinese (25)(25 分) Given an integer with no more than 9 digits, you are suppose ...
- 配置Spring.NET
先引入关键的程序集 Common.Logging.dll Spring.Core.dll 在配置文件配置中: <configSections> ...... <sectionGrou ...
- HDU1042 A * B Problem Plus
A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 1568: [JSOI2008]Blue Mary开公司(超哥线段树)
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1198 Solved: 418 Descr ...
- Lucene.Net 精品教程
http://www.cnblogs.com/piziyimao/archive/2013/01/31/2887072.html
- leetcode 【 Search in Rotated Sorted Array 】python 实现
题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 ...
- poj2002 hash+邻接表优化Squares
Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 17487 Accepted: 6643 Descript ...
- java 数据库连接 驱动相关参数
mysql: driverClass=com.mysql.jdbc.Driver connectionURL=jdbc:mysql://localhost:3306/shiro userId=root ...
- RUBY 模拟rtsp消息
require 'rtsp/client' require 'log_switch' require 'socket' RTSP::Client.log? # => false RTSP::Cl ...
- 【bzoj4836】[Lydsy2017年4月月赛]二元运算 分治+FFT
题目描述 定义二元运算 opt 满足 现在给定一个长为 n 的数列 a 和一个长为 m 的数列 b ,接下来有 q 次询问.每次询问给定一个数字 c 你需要求出有多少对 (i, j) 使得 a_ ...