- 扫雷游戏
- 2015-12-05 12:58:07 @
代码
program mine1;
label
438;
var
map:array[0..101,0..101] of char;
num:array[1..100,1..100] of 0..8;
m,n,a,b,mine,temp:longint;
begin
readln(m,n);
for a:=1 to n do
for b:=1 to m do
438:
begin
read(map[a,b]);
if not((map[a,b]='?') or (map[a,b]='*'))
then goto 438;
end;
for a:=1 to n do
begin
for b:=1 to m do
if map[a,b]='?' then
begin
mine:=0;
if map[a-1,b-1]='*' then mine:=mine+1;
if map[a+1,b-1]='*' then mine:=mine+1;
if map[a+1,b+1]='*' then mine:=mine+1;
if map[a-1,b+1]='*' then mine:=mine+1;
if map[a-1,b]='*' then mine:=mine+1;
if map[a+1,b]='*' then mine:=mine+1;
if map[a,b-1]='*' then mine:=mine+1;
if map[a,b+1]='*' then mine:=mine+1;
num[a,b]:=mine;
end;
end;
for a:=1 to n do
begin
for b:=1 to m do
if map[a,b]='*' then
write('*')
else
write(num[a,b]);
writeln;
end;
end.
6 条评论
-
pascalzzk LV 8 @ 2016-11-06 10:19:21
编译成功
Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
foo.pas(7,14) Note: Local variable "temp" not used
Linking foo.exe
43 lines compiled, 0.0 sec, 28832 bytes code, 1268 bytes data
1 note(s) issued
测试数据 #0: TimeLimitExceeded, time = 609 ms, mem = 828 KiB, score = 0
测试数据 #1: TimeLimitExceeded, time = 609 ms, mem = 832 KiB, score = 0
测试数据 #2: TimeLimitExceeded, time = 593 ms, mem = 828 KiB, score = 0
测试数据 #3: TimeLimitExceeded, time = 609 ms, mem = 828 KiB, score = 0
测试数据 #4: TimeLimitExceeded, time = 609 ms, mem = 832 KiB, score = 0
测试数据 #5: TimeLimitExceeded, time = 609 ms, mem = 832 KiB, score = 0
测试数据 #6: TimeLimitExceeded, time = 609 ms, mem = 828 KiB, score = 0
测试数据 #7: TimeLimitExceeded, time = 593 ms, mem = 828 KiB, score = 0
测试数据 #8: TimeLimitExceeded, time = 609 ms, mem = 828 KiB, score = 0
测试数据 #9: TimeLimitExceeded, time = 609 ms, mem = 832 KiB, score = 0
TimeLimitExceeded, time = 6058 ms, mem = 832 KiB, score = 0
你的代码 -
2016-05-24 13:54:01@
#include<cstdio>
const int maxn=101;
char pic[maxn][maxn];
int num[maxn][maxn];
int main(){
int r,c;
char eat;
scanf("%d%d",&r,&c);
for(int i=0;i<r;i++)
scanf("%s",&pic[i]);
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
{
int cnt=0;
for(int dx=-1;dx<=1;dx++)
for(int dy=-1;dy<=1;dy++)
if((dx||dy)&&(i+dx>=0&&i+dx<r&&j+dy>=0&&j+dy<c)&&pic[i+dx][j+dy]=='*') cnt++;
if(pic[i][j]=='*') num[i][j]=-1;
else num[i][j]=cnt;
}
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(num[i][j]<0) printf("*");
else printf("%d",num[i][j]);
}
printf("\n");
}
return 0;
}
懵逼脸 -
2016-04-05 16:39:05@
...
-
2015-12-10 21:17:07@
同感我才20……
-
2015-12-07 20:32:01@
水题怎么可能80分?
-
2015-12-07 17:46:42@
也许是数据不同,也有可能是评测机的原因(Vijos的评测机总能创造各种奇迹)。--
- 1