#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的更多相关文章

  1. The Trip PC/UVa IDs: 110103/10137, Popularity: B, Success rate: average Level: 1

    #include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...

  2. PC/UVa 题号: 110106/10033 Interpreter (解释器)题解 c语言版

    , '\n'); #include<cstdio> #include<iostream> #include<string> #include<algorith ...

  3. 挑战编程PC/UVa Stern-Brocot代数系统

    /* Stern-Brocot代数系统 Stern-Brocot树是一种生成所有非负的最简分数m/n的美妙方式. 其基本方式是从(0/1, 1/0)这两个分数开始, 根据需要反复执行如下操作: 在相邻 ...

  4. PC/UVa 题号: 110105/10267 Graphical Editor (图形化编辑器)题解

    #include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...

  5. PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解

    #include <string> #include <iostream> #include <cstring> #include <algorithm> ...

  6. 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 ...

  7. UVa 122 (二叉树的层次遍历) Trees on the level

    题意: 输入一颗二叉树,按照(左右左右, 节点的值)的格式.然后从上到下从左到右依次输出各个节点的值,如果一个节点没有赋值或者多次赋值,则输出“not complete” 一.指针方式实现二叉树 首先 ...

  8. Uva 122 树的层次遍历 Trees on the level lrj白书 p149

    是否可以把树上结点的编号,然后把二叉树存储在数组中呢?很遗憾如果结点在一条链上,那将是2^256个结点 所以需要采用动态结构 首先要读取结点,建立二叉树addnode()+read_input()承担 ...

  9. Mineweep(扫雷)

    题目描述: 每周一题之2  Mineweep(扫雷) Minesweeper (扫雷) PC/UVa IDs: 110102/10189, Popularity: A, Success rate: h ...

随机推荐

  1. 图文详解YUV420数据格式

    YUV格式有两大类:planar和packed.对于planar的YUV格式,先连续存储所有像素点的Y,紧接着存储所有像素点的U,随后是所有像素点的V.对于packed的YUV格式,每个像素点的Y,U ...

  2. UVA 10054 The Necklace

    完全就是哭瞎的节奏···QAQ 又是图论··· 题意:有一种项链,每个珠子上有两种颜色,相同颜色的两颗珠子的两头相连,如果能连成环输出珠子的顺序,不能连成环输出"some beads may ...

  3. HDU 5882 Balanced Game

    Balanced Game Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  4. Oracle 数据乱码

    原文 Oracle 数据乱码 服务器配置环境变量 NLS_LANG:American_america.ZHS16GBK        

  5. 仿网易新闻客户端头条ViewPager嵌套实例

    要点: 1.重写组件public boolean onInterceptTouchEvent(MotionEvent event)方法 2.正确使用requestDisallowInterceptTo ...

  6. 【Python】python读取文件操作mysql

    尾大不掉,前阵子做检索测试时,总是因为需要业务端操作db和一些其他服务,这就使得检索测试对环境和数据依赖性特别高,极大提高了测试成本. Mock服务和mysql可以很好的解决这个问题,所以那阵子做了两 ...

  7. 【剑指offer 面试题23】从上往下打印二叉树

    思路: 没啥好说的,BFS. C++: #include <iostream> #include <queue> using namespace std; struct Tre ...

  8. CSAPP(1):数字的计算机表示——课后题

    2.65 int even_ones(unsigned x) 要求:return 1 when x contains an even number of 1s; 0 otherwise. 假设int ...

  9. BestCoder Round #76 解题报告

    DZY Loves Partition [思路] 贪心 [代码] #include <iostream> using namespace std; typedef long long ll ...

  10. mybatis系列-07-输出映射

    7.1     resultType 使用resultType进行输出映射,只有查询出来的列名和pojo中的属性名一致,该列才可以映射成功. 如果查询出来的列名和pojo中的属性名全部不一致,没有创建 ...