mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-08 02:13:51 +08:00
Add FZOI Codes
This commit is contained in:
46
FZOI/[NOIP2015 普及组] 扫雷游戏.cpp
Normal file
46
FZOI/[NOIP2015 普及组] 扫雷游戏.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include<stdio.h>
|
||||
char a[101][101];
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
int n, m;
|
||||
scanf("%d%d", &n,&m);
|
||||
getchar();
|
||||
for(int i = 1; i <= n; i ++ )
|
||||
{
|
||||
for(int j = 1; j <= m; j ++ )
|
||||
{
|
||||
scanf("%c", &a[i][j]);
|
||||
}
|
||||
getchar();
|
||||
|
||||
}
|
||||
for (int i = 1; i <= n; i ++ )
|
||||
{
|
||||
for (int j = 1; j <= m; j ++ )
|
||||
{
|
||||
|
||||
if (a[i][j] == '*')
|
||||
{
|
||||
printf("*");
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = 0;
|
||||
if (a[i][j - 1] == '*') count ++ ;
|
||||
if (a[i][j + 1] == '*') count ++ ;
|
||||
if (a[i + 1][j - 1] == '*') count ++ ;
|
||||
if (a[i - 1][j + 1] == '*') count ++ ;
|
||||
if (a[i + 1][j] == '*') count ++ ;
|
||||
if (a[i - 1][j] == '*') count ++ ;
|
||||
if (a[i + 1][j + 1] == '*') count ++ ;
|
||||
if (a[i - 1][j - 1] == '*') count ++ ;
|
||||
printf("%c", count+'0');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user