📄 1768.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1768 on 2005-09-16 at 23:43:41 */
#include <stdio.h>
int main()
{
int n, num[11][11];
int i, j, touchMine, k = 0;
char touched[11][11];
while(scanf("%d", &n) == 1) {
if(k != 0) {
putchar('\n');
}
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
num[i][j] = 0;
}
}
while(getchar() != '\n')
;
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
if(getchar() == '*') {
if(i > 0) {
if(j > 0) {
num[i-1][j-1]++;
}
num[i-1][j]++;
if(j < n-1) {
num[i-1][j+1]++;
}
}
if(i < n-1) {
num[i+1][j]++;
if(j < n-1) {
num[i+1][j+1]++;
}
}
if(j < n-1) {
num[i][j+1]++;
}
if(j > 0) {
num[i][j-1]++;
if(i < n-1) {
num[i+1][j-1]++;
}
}
num[i][j] = -50;
}
}
while(getchar() != '\n')
;
}
touchMine = 0;
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
if(getchar() == 'x') {
touched[i][j] = 1;
if(num[i][j] < 0) {
touchMine = 1;
}
} else {
touched[i][j] = 0;
}
}
while(getchar() != '\n')
;
}
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++) {
if(touchMine && (num[i][j] < 0)) {
putchar('*');
} else if(touched[i][j]) {
printf("%d", num[i][j]);
} else {
putchar('.');
}
}
putchar('\n');
}
k++;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -