-
Notifications
You must be signed in to change notification settings - Fork 2
/
10189.cpp
executable file
·111 lines (91 loc) · 1.58 KB
/
10189.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <iostream>
using namespace std ;
int main()
{
int **Minesweep = new int *[ 100 ] ;
Minesweep-- ;
for( int i = 1 ; i <= 100 ; i++ )
{
Minesweep[ i ] = new int [ 100 ] ;
Minesweep[ i ] -- ;
for( int k = 1 ; k <= 100 ; k++ )
{
Minesweep[ i ][ k ] = 0 ;
}
}
int n , m ;
char input ;
for( int i = 1 ; ; i++ )
{
cin >> n >> m ;
if( n == 0 && m == 0 )
{
break ;
}
for( int j = 1 ; j <= n ; j++ )
{
for( int k = 1 ; k <= m ; k++ )
{
cin >> input ;
if( input == '*' )
{
Minesweep[ j ][ k ] = -9 ;
if( j > 1 )
{
if( k > 1 )
{
Minesweep[ j - 1 ][ k - 1 ] ++ ;
}
Minesweep[ j - 1 ][ k ] ++ ;
if( k < m )
{
Minesweep[ j - 1 ][ k + 1 ] ++ ;
}
}
if( k > 1 )
{
Minesweep[ j ][ k - 1 ] ++ ;
}
if( k < m )
{
Minesweep[ j ][ k + 1 ] ++ ;
}
if( j < n )
{
if( k > 1 )
{
Minesweep[ j + 1 ][ k - 1 ] ++ ;
}
Minesweep[ j + 1 ][ k ] ++ ;
if( k < m )
{
Minesweep[ j + 1 ][ k + 1 ] ++ ;
}
}
}
}
}
if( i != 1 )
{
cout << endl ;
}
cout << "Field #" << i << ":" << endl ;
for( int j = 1 ; j <= n ; j++ )
{
for( int k = 1 ; k <= m ; k++ )
{
if( Minesweep[ j ][ k ] < 0 )
{
cout << "*" ;
}
else
{
cout << Minesweep[ j ][ k ] ;
}
Minesweep[ j ][ k ] = 0 ;
}
cout << endl ;
}
}
return 0 ;
}