Minesweeper PC/UVa IDs: 110102/10189, Popularity: A,Success rate: high Level: 1
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<iterator>
#include<cstring> using namespace std; int n, m;
char x[101][101]; void calc()
{
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(x[i][j]=='*')
{
putchar('*');
}
else
{ int count=0;
for(int k=-1;k<=1;k++)
for(int l=-1;l<=1;l++)
{
int a,b;
a=i+k;
b=j+l; if(a>=0 && a<n && b>=0 && b<m && x[a][b]=='*')
{
count++;
} }
printf("%d", count);
} }
printf("\n"); }
} int main()
{
int count=0;
while(scanf("%d %d", &n, &m)!=EOF)
{
if(n==0&&m==0)
break;
for(int i=0;i<n;i++)
{
memset(x[i], 0, m);
scanf("%s", x[i]);
} if(count>0)
printf("\n"); count++;
printf("Field #%d:\n", count);
calc();
} return 0;
}
Minesweeper PC/UVa IDs: 110102/10189, Popularity: A,Success rate: high Level: 1的更多相关文章
- The Trip PC/UVa IDs: 110103/10137, Popularity: B, Success rate: average Level: 1
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
- PC/UVa 题号: 110106/10033 Interpreter (解释器)题解 c语言版
, '\n'); #include<cstdio> #include<iostream> #include<string> #include<algorith ...
- 挑战编程PC/UVa Stern-Brocot代数系统
/* Stern-Brocot代数系统 Stern-Brocot树是一种生成所有非负的最简分数m/n的美妙方式. 其基本方式是从(0/1, 1/0)这两个分数开始, 根据需要反复执行如下操作: 在相邻 ...
- PC/UVa 题号: 110105/10267 Graphical Editor (图形化编辑器)题解
#include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...
- PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解
#include <string> #include <iostream> #include <cstring> #include <algorithm> ...
- PC/UVa 题号: 110101/100 The 3n+1 problem (3n+1 问题)
The 3n + 1 problem Background Problems in Computer Science are often classified as belonging to a ...
- UVa 122 (二叉树的层次遍历) Trees on the level
题意: 输入一颗二叉树,按照(左右左右, 节点的值)的格式.然后从上到下从左到右依次输出各个节点的值,如果一个节点没有赋值或者多次赋值,则输出“not complete” 一.指针方式实现二叉树 首先 ...
- Uva 122 树的层次遍历 Trees on the level lrj白书 p149
是否可以把树上结点的编号,然后把二叉树存储在数组中呢?很遗憾如果结点在一条链上,那将是2^256个结点 所以需要采用动态结构 首先要读取结点,建立二叉树addnode()+read_input()承担 ...
- Mineweep(扫雷)
题目描述: 每周一题之2 Mineweep(扫雷) Minesweeper (扫雷) PC/UVa IDs: 110102/10189, Popularity: A, Success rate: h ...
随机推荐
- FFmpeg解码H264及swscale缩放详解
本文概要: 本文介绍著名开源音视频编解码库ffmpeg如何解码h264码流,比较详细阐述了其h264码流输入过程,解码原理,解码过程.同时,大部分应用环境下,以原始码流视频大小展示并不是最佳方式,因此 ...
- function 中定义函数的默认返回值,
result有默认值的int类型的为0,string类型的为‘’,tobject类型的为nil等等
- geusture for chrome cfg
{ "name": "Chrome Gestures", "version": "1.13.4", "norm ...
- [Everyday Mathematics]20150201
设数列 $\sed{a_n}$ 单调递减趋于零, 证明 $\dps{\vsm{n}a_n}$ 收敛当且仅当 $\dps{\vsm{n}3^k a_{3^k}}$ 收敛.
- Mybatis拦截器介绍
拦截器的一个作用就是我们可以拦截某些方法的调用,我们可以选择在这些被拦截的方法执行前后加上某些逻辑,也可以在执行这些被拦截的方法时执行自己的逻辑而不再执行被拦截的方法.Mybatis拦截器设计的一个初 ...
- [Irving]字符串相似度-字符编辑距离算法(c#实现)
编辑距离(Edit Distance),又称Levenshtein距离,是指两个字串之间,由一个转成另一个所需的最少编辑操作次数.许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字 ...
- 告别where 1=1 最佳方案分享
已经有2年没有用过where 1=1了,没想到换了家公司后,又让我看到了它.在网络上面搜索了一下,发现没有人提供一个比较好的方案来解决这一问题.很多人说可以让数据库的优化机制去处理,但是,我想对于大部 ...
- MFC DLL 资源模块句柄切换[转]
以前写MFC的DLL的时候,总会在自动生成的代码框架里看到提示,需要在每一个输出的函数开始添加上 AFX_MANAGE_STATE(AfxGetStaticModuleState()).一直不明白这样 ...
- Redis3.0 Install
Installation Download, extract and compile Redis with: $ wget http://download.redis.io/releases/redi ...
- Hadoop中FileSystem的append方法
今天在使用Hadoop 1.1.2版本进行FileSystem的append操作时报以下异常: org.apache.hadoop.ipc.RemoteException: java.io.IOExc ...