poj 2612 Mine Sweeper

Mine Sweeper

Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6429 Accepted: 2500

Description

The game Minesweeper is played on an n by n grid. In this grid are hidden m mines, each at a distinct grid location. The player repeatedly touches grid positions. If a position with a mine is touched, the mine explodes and the player loses. If a positon not containing a mine is touched, an integer between 0 and 8 appears denoting the number of adjacent or diagonally adjacent grid positions that contain a mine. A sequence of moves in a partially played game is illustrated below.
poj 2612 Mine Sweeper

Here, n is 8, m is 10, blank squares represent the integer 0, raised squares represent unplayed positions, and the figures resembling asterisks represent mines. The leftmZ??">vc3QgaW1hZ2UgcmVwcmVzZW50cyB0aGUgcGFydGlhbGx5IHBsYXllZCBnYW1lLiBGcm9tIHRoZSBmaXJzdCBpbWFnZSB0byB0aGUgc2Vjb25kLCB0aGUKIHBsYXllciBoYXMgcGxheWVkIHR3byBtb3ZlcywgZWFjaCB0aW1lIGNob29zaW5nIGEgc2FmZSBncmlkIHBvc2l0aW9uLiBGcm9tIHRoZSBzZWNvbmQgaW1hZ2UgdG8gdGhlIHRoaXJkLCB0aGUgcGxheWVyIGlzIG5vdCBzbyBsdWNreTsgaGUgY2hvb3NlcyBhIHBvc2l0aW9uIHdpdGggYSBtaW5lIGFuZCB0aGVyZWZvcmUgbG9zZXMuIFRoZSBwbGF5ZXIgd2lucyBpZiBoZSBjb250aW51ZXMgdG8gbWFrZSBzYWZlIG1vdmVzIHVudGlsIG9ubHkgbSB1bnBsYXllZAogcG9zaXRpb25zIHJlbWFpbjsgdGhlc2UgbXVzdCBuZWNlc3NhcmlseSBjb250YWluIHRoZSBtaW5lcy4gPGJyPgo8YnI+CllvdXIgam9iIGlzIHRvIHJlYWQgdGhlIGluZm9ybWF0aW9uIGZvciBhIHBhcnRpYWxseSBwbGF5ZWQgZ2FtZSBhbmQgdG8gcHJpbnQgdGhlIGNvcnJlc3BvbmRpbmcgYm9hcmQuIDxicj4KCjxwIGNsYXNzPQ=="pst">InputThe first line of input contains a single postitive integer n OutputYour output should represent the board, with each position filled in appropriately. Positions that have been touched and do not contain a mine should contain an integer between 0 and 8. If a mine has been touched, all positions with a mine should contain an asterisk. All other positions should contain a period.

Sample Input

8 ...**..* ......*. ....*... ........ ........ .....*.. ...**.*. .....*.. xxx..... xxxx.... xxxx.... xxxxx... xxxxx... xxxxx... xxx..... xxxxx...

Sample Output

001..... 0013.... 0001.... 00011... 00001... 00123... 001..... 00123...

注意:如果踩到地雷,要把所有地雷表示出来;

#include using namespace std; #define MAX 12 int n; char map[MAX][MAX],ans[MAX][MAX]; int count(int i,int j,int n){ int ans=0; if (map[i-1][j-1]=='*' && i-1>=0 && j-1>=0) ans++; if (map[i-1][j]=='*' && i-1>=0) ans++; if (map[i-1][j+1]=='*' && i-1>=0 && j+1=0) ans++; if (map[i][j]=='*') ans++; if (map[i][j+1]=='*' && j+1=0) ans++; if (map[i+1][j]=='*' && i+1>n){ for (int i=0;i>map[i][j]; int flag=0; for (int i=0;i>ans[i][j]; if (map[i][j]=='*' && ans[i][j]=='x') flag=1; if (ans[i][j]=='x'){ int k=count(i,j,n); ans[i][j]=k+'0'; } } } for (int i=0;i

点击复制链接 与好友分享!回本站首页
您对本文章有什么意见或着疑问吗?请到论坛讨论您的关注和建议是我们前行的参考和动力
上一篇:HDU4451Dressing(计数)
下一篇:poj 2601 Simple calculations
相关文章

POJ3621最优比率生成环 01分数规划问题

poj 1928

poj 3728 tarjan+带权路径并查集

poj 3321

POJ 1664 放苹果 递推

poj 1631

poj模拟题总结(一)

POJ 1083

POJ 1952 BUY LOW, BUY LOWER

poj 1195

图文推荐

poj 2612 Mine Sweeper
ZOJ 3640 Help Me
poj 2612 Mine Sweeper
CF 518C(Anya and
poj 2612 Mine Sweeper
hdu 1016 Prime R
UVA - 11987 - A

分类:默认分类 时间:2015-03-01 人气:7
本文关键词:
分享到:

相关文章

Copyright (C) quwantang.com, All Rights Reserved.

趣玩堂 版权所有 京ICP备15002868号

processed in 0.064 (s). 10 q(s)