FZU OJ 1056 :扫雷游戏
Accept: 2624 Submit: 6903
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
你的任务是在已知地雷出现位置的情况下,得到各个方块中的数据。
经过处理应得到
Input
Output
Sample Input
Sample Output
一开始想着这道题要用dfs之类的算法, 后来发现想多了。。。直接遍历一遍记录就可以了,但是没有看到每组输出后有一颗空行,导致错了一次。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
const int maxn=1e6+10;
char a[110][110];
int b[110][110];
int n,m;
int main()
{
while(cin>>m>>n&&n!=EOF&&m!=EOF)
{
if(n==0&&m==0) break;
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
cin>>a[i][j];
memset(b,0,sizeof(b));
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]=='*')
{
b[i-1][j]+=1;
b[i-1][j-1]+=1;
b[i-1][j+1]+=1;
b[i][j-1]+=1;
b[i][j+1]+=1;
b[i+1][j+1]+=1;
b[i+1][j]+=1;
b[i+1][j-1]+=1;
}
}
}
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]=='*')
{
cout<<"*";
continue;
}
else cout<<b[i][j];
}
cout<<endl;
}
cout<<endl;
}
return 0;
}
FZU OJ 1056 :扫雷游戏的更多相关文章
- FZU 1056 扫雷游戏【搜索】
Accept: 2584 Submit: 6790Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description 扫雷是 ...
- FZU 1056 扫雷游戏
水题.统计一下周围有几个雷. #include<cstdio> #include<cstring> #include<cmath> #include<algo ...
- 洛谷 P2670 扫雷游戏==Codevs 5129 扫雷游戏
题目描述 扫雷游戏是一款十分经典的单机小游戏.在n行m列的雷区中有一些格子含有地雷(称之为地雷格),其他格子不含地雷(称之为非地雷格).玩家翻开一个非地雷格时,该格将会出现一个数字——提示周围格子中有 ...
- 原生javascript扫雷游戏
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Java练习(模拟扫雷游戏)
要为扫雷游戏布置地雷,扫雷游戏的扫雷面板可以用二维int数组表示.如某位置为地雷,则该位置用数字-1表示, 如该位置不是地雷,则暂时用数字0表示. 编写程序完成在该二维数组中随机布雷的操作,程序读入3 ...
- JAVA_扫雷游戏(布置地雷)
1.要为扫雷游戏布置地雷,扫雷游戏的扫雷面板可以用二维int数组表示.如某位置为地雷,则该位置用数字-1表示, 如该位置不是地雷,则暂时用数字0表示. 编写程序完成在该二维数组中随机布雷的操作,程序读 ...
- [LeetCode] Minesweeper 扫雷游戏
Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representin ...
- C语言二维数组实现扫雷游戏
#include<stdio.h> //使用二维数组实现 扫雷 int main() { char ui[8][8]={ '+','+','+','+','+','+','+','+', ...
- 【Android】自己动手做个扫雷游戏
1. 游戏规则 扫雷是玩法极其简单的小游戏,点击玩家认为不存在雷的区域,标记出全部地雷所在的区域,即可获得胜利.当点击不包含雷的块的时候,可能它底下存在一个数,也可能是一个空白块.当点击中有数字的块时 ...
随机推荐
- 96D - Police Stations
96D - Police Stations 思路:bfs,从所有的警察局开始bfs,因为bfs的深度一样,而且题目给的树保证满足条件,所以不用考虑深度. 如果搜索到一个点a,他的下一个点b已经被搜索过 ...
- 模块commonjs AMD UMD
commonjs是用在服务器端的,同步的,如nodejs amd, cmd是用在浏览器端的,异步的,如requirejs和seajs 其中,amd先提出,cmd是根据commonjs和amd基础上提出 ...
- 拓扑排序 Topological Sort
2018-05-02 16:26:07 在计算机科学领域,有向图的拓扑排序或拓扑排序是其顶点的线性排序,使得对于从顶点u到顶点v的每个有向边uv,u在排序中都在v前.例如,图形的顶点可以表示要执行的任 ...
- ArcGIS API for Windows Phone开发实例(4):点击查看超市信息 --- 关于使用InforWindow
菩提老王的葡萄架:作品 地址:http://blog.newnaw.com/?p=696
- js获取表格视图所选行号的ids
实例化数组 遍历所选行push到数组中 将数组join转换为以,分割的字符串 /*获取指定id的datagrid的表格视图的选择的ids*/ function getDataGridSelectRow ...
- python-day18--匿名函数
一.lambda表达式 1.匿名函数的核心:一些简单的需要用函数去解决的问题,匿名函数的函数体只有一行 2.参数可以有多个,用逗号隔开 3.返回值和正常的函数一样可以是任意的数据类型 4.练习: 请把 ...
- POJ-3009 Curling 2.0 (DFS)
Description On Planet MM-21, after their Olympic games this year, curling is getting popular. But th ...
- Rotate Array 旋转数组 JS 版本解法
Given an array, rotate the array to the right by k steps, where k is non-negative. 给定一个数组,并且给定一个非负数的 ...
- sha256 in C language
sha256.h #ifndef _SHA256_H#define _SHA256_H #ifndef uint8#define uint8 unsigned char#endif #ifndef u ...
- sgu 121. Bridges painting 列举情况 难度:1
121. Bridges painting time limit per test: 0.25 sec. memory limit per test: 4096 KB New Berland cons ...