- 送给圣诞夜的极光
- 2009-03-09 17:52:07 @
const
f:array[1..12,1..2]of -2..2=((1,0),(2,0),(1,-1),(0,-2),(0,-1),(-1,-1),(-2,0),(-1,0),(-1,1),(0,1),(0,2),(1,1));
var
map:array[-5..200,-5..200]of boolean;
i,j,m,n,tt:integer;
c:char;
procedure search(x,y:integer);
var
i:integer;
begin
for i:=1 to 12 do
if map[x+f,y+f] then begin
map[x+f,y+f]:=false;
search(x+f,y+f);
end;
end;
begin
readln(n,m);
for i:=1 to n do begin
for j:=1 to m do begin
read(c);
if c='#' then map:=true;
end;
readln;
end;
for i:=1 to n do
for j:=1 to m do
if map then begin
map:=false;
inc(tt);
search(i,j);
end;
writeln(tt);
end.
program P1051;
const e :array[1..2,1..12] of integer=((0,0,0,0,1,1,-1,-1,1,2,-1,-2),(-1,-2,1,2,1,-1,1,-1,0,0,0,0));
var
a :array[-1..102,-1..102] of boolean;
n,m,i,j,num :longint;
c :char;
procedure floodfill(p,q:integer);
var ii :integer;
begin
a[p,q] := false;
for ii := 1 to 12 do
if a[p,q] then
floodfill(p+e[1,ii],q+e[2,ii])
end;
begin
readln(n,m);
for i := 1 to n do
begin
for j := 1 to m do
begin
read(c);
if c='#' then a:=true;
end;
readln;
end;
for i := 1 to n do
for j := 1 to m do
if a then
begin
inc(num);
floodfill(i,j);
end;
writeln(num);
end.
为什么一个10分一个满分...我觉得是一样的啊
1 条评论
-
st10159 LV 8 @ 2010-03-06 21:26:01
p1051
子程序中的"if a[p,q] then "应该改为"if a[p+e[1,ii],q+e[2,ii]] then " !!
- 1