mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-03 18:56:26 +00:00
P2670 [NOIP2015 普及组] 扫雷游戏
R63302737
This commit is contained in:
parent
842ce30e1f
commit
59c9801478
33
Luogu/P2670/P2670.cpp
Normal file
33
Luogu/P2670/P2670.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m;
|
||||
char g[105][105];
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> g[i] + 1;
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
if (g[i][j] != '*') {
|
||||
int sum = 0;
|
||||
sum += g[i - 1][j - 1] == '*';
|
||||
sum += g[i - 1][j] == '*';
|
||||
sum += g[i - 1][j + 1] == '*';
|
||||
sum += g[i][j - 1] == '*';
|
||||
sum += g[i][j + 1] == '*';
|
||||
sum += g[i + 1][j - 1] == '*';
|
||||
sum += g[i + 1][j] == '*';
|
||||
sum += g[i + 1][j + 1] == '*';
|
||||
cout << sum;
|
||||
} else {
|
||||
cout << g[i][j];
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user