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 ...
随机推荐
- HDU 5876 Sparse Graph
Sparse Graph Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)To ...
- 在Ubuntu下卸载Apache
卸载Apache 转自:http://blog.csdn.net/chmo2011/article/details/7026384 1. 删除apache 代码: $ sudo apt-get --p ...
- HDU 2222 (AC自动机模板题)
题意: 给一个文本串和多个模式串,求文本串中一共出现多少次模式串 分析: ac自动机模板,关键是失配函数 #include <map> #include <set> #incl ...
- <转>DNS服务系列之二:DNS区域传送漏洞的安全案例
DNS区域传送(DNS zone transfer)指的是一台备用服务器使用来自主服务器的数据刷新自己的域(zone)数据库.这为运行中的DNS服务提供了一定的冗余度,其目的是为了防止主的域名服务器因 ...
- ASM中的别名
在ASM中的别名,是为了方便管理. 在ASM中创建别名,一种是在RDBMS中创建,另外一种是在ASM中创建,区别就是在ASM中创建的别名,在RDBMS中是不可见的. 在RDBMS中创建别名: SQL& ...
- redo文件二
为什么要引入LGWR后台进程和redo log buffer 如果使用前台进程来将redo的信息写入到redo日志文件组中,那么会导致并发的前台进程对redo日志文件组的争用,从而使用后台进程LGWR ...
- C#插入排序详解
这几天一直在研究算法,也算有点心得,现在跟大家分享一下,我是用C#做的 排序算法是想要成为大虾程序员必须要掌握的技术,它其实也是一种思想,你对算法熟悉,对以后编程有很大帮助 算法思路 ⒈ 从第一个元素 ...
- SVM原理简介
本文只是简单介绍一下SVM的理论框架,想要详细了解当中细节问题处理可以参看后续章节或者网上各种详细资料.推荐Andrew Ng的斯坦福大学机器学习课程. 年代中期发展起来的基于统计学习理论的一种机器学 ...
- Python的列表排序
Python的列表排序 本文为转载,源地址为:http://blog.csdn.net/horin153/article/details/7076321 在 Python 中, 当需要对一个 list ...
- (原创)spring mvc和jersey rest 组合使用时单例对像实例化两次的BUG及解决办法
项目中没用spring 的restTemplate 而是采用 jersey来做rest 的实现,一直用着,也没发现有什么不对,后来加入了,以quartz用硬编码方式实现,结果启动项目的时候报错 ,具体 ...