-
Notifications
You must be signed in to change notification settings - Fork 0
/
10189 - Minesweeper.cpp
63 lines (53 loc) · 1.36 KB
/
10189 - Minesweeper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<sstream>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define sc scanf
#define pf printf
#define Pi 2*acos(0.0)
#define Mo 10000007
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
int t=1;
int n,m,min;
while(cin>>n>>m)
{
if(n==0 || m==0) break;
if (t > 1)
cout<<endl;
//use boarder
vector<vector<char> > f(n + 5, vector<char>(m + 5, '.'));
for (int i = 1; i<= n; ++i)
for (int j = 1; j <= m; ++j)
cin>>f[i][j];
cout << "Field #" << t++ << ":" << endl;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (f[i][j] == '*') //mine print
cout<<'*';
else
{
min = 0;
for (int a = i - 1; a <= i + 1; ++a)
for (int b = j - 1; b <= j + 1; ++b) //safezone
if (f [a][b] == '*')
++min;
cout<<min;
}
}
cout<<endl;
}
}
return 0;
}