博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Minesweeper
阅读量:3944 次
发布时间:2019-05-24

本文共 1570 字,大约阅读时间需要 5 分钟。

文章目录

题目描述

Minesweeper Have you ever played Minesweeper? This cute little game comes with a certain operating system whose name we can’t remember. The goal of the game is to find where all the mines are located within a M x N field. The game shows a number in a square which tells you how many mines there are adjacent to that square. Each square has at most eight adjacent squares. The 4 x 4 field on the left contains two mines, each represented by a ``*’’ character. If we represent the same field by the hint numbers described above, we end up with the field on the right: … … .… … 100 2210 110 1110

输入

The input will consist of an arbitrary number of fields. The first line of each field contains two integers n and m ( 0 < n, m$ \le$100) which stand for the number of lines and columns of the field, respectively. Each of the next n lines contains exactly m characters, representing the field. Safe squares are denoted by .'' and mine squares by*,’’ both without the quotes. The first field line where n = m = 0 represents the end of input and should not be processed.

输出

For each field, print the message Field #x: on a line alone, where x stands for the number of the field starting from 1. The next n lines should contain the field with the ``.’’ characters replaced by the number of mines adjacent to that square. There must be an empty line between field outputs.

样例输入

4 4

.
3 5
**…
.*…
0 0

样例输出

Field #1:

100
2210
1
10
1110

Field #2:

**100
33200
1*100

c语言AC代码

#include 
char a[101][101]; int n,m;void print(int cou){
int i,j; for(i=0;i

转载地址:http://sflwi.baihongyu.com/

你可能感兴趣的文章
Parsing XML Data
查看>>
Optimizing Downloads for Efficient Network Access
查看>>
Minimizing the Effect of Regular Updates
查看>>
Redundant Downloads are Redundant
查看>>
Modifying your Download Patterns Based on the Connectivity Type
查看>>
Supporting Different Screen Sizes支持不同的屏幕尺寸
查看>>
Supporting Different Densities 支持各种屏幕密度
查看>>
Implementing Adaptative UI Flows 实施自适应用户界面流程
查看>>
Crossfading Two Views 淡入淡出的两种观点
查看>>
Using ViewPager for Screen Slides 使用屏幕幻灯片ViewPager
查看>>
Displaying Card Flip Animations 显示卡片翻转动画
查看>>
Zooming a View 缩放视图
查看>>
Animating Layout Changes 动画布局的更改
查看>>
Controlling Your App’s Volume and Playback 控制应用程序的音量和播放
查看>>
Managing Audio Focus 管理音频焦点
查看>>
Dealing with Audio Output Hardware 处理音频输出硬件设备
查看>>
Monitoring the Battery Level and Charging State 监测电池电量和充电状态
查看>>
Determining and Monitoring the Docking State and Type 判断并监测设备的停驻状态与类型
查看>>
Determining and Monitoring the Connectivity Status 根据网络连接状况去省电
查看>>
Manipulating Broadcast Receivers On Demand 按需操控广播接收
查看>>