From 59c9801478149dac53d89837eb2df7f70d2fb483 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 21 Nov 2021 19:06:54 +0800 Subject: [PATCH] =?UTF-8?q?P2670=20[NOIP2015=20=E6=99=AE=E5=8F=8A=E7=BB=84?= =?UTF-8?q?]=20=E6=89=AB=E9=9B=B7=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R63302737 --- Luogu/P2670/P2670.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Luogu/P2670/P2670.cpp diff --git a/Luogu/P2670/P2670.cpp b/Luogu/P2670/P2670.cpp new file mode 100644 index 00000000..a1894be7 --- /dev/null +++ b/Luogu/P2670/P2670.cpp @@ -0,0 +1,33 @@ +#include + +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; +}