| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
怎么错了?大家看看。。。怎么错了?
大家看看。。。
var
xx,yy,m,n,i,j,tot,code:integer;
house:array[0..21,0..21]of char;
went:array[0..21,0..21]of boolean;
st,c:string;a:char;men:boolean;
procedure search(x,y:integer);
begin
if not went[x,y] then begin
went[x,y]:=true;
inc(tot);
if house[x,y-1]<>'#' then search(x,y-1);
if house[x,y+1]<>'#' then search(x,y+1);
if house[x-1,y]<>'#' then search(x-1,y);
if house[x+1,y]<>'#' then search(x+1,y);
end;
end;
begin
readln(m,n);
while not((m=0)and(n=0)) do begin
fillchar(house,sizeof(house),' ');
fillchar(went,sizeof(went),false);
tot:=0;men:=false;
for i:= 1 to n do begin
for j:= 1 to m do
read(house[i,j]);
if not men then
for j:= 1 to m do
if house[i,j]='@' then begin
xx:=i;yy:=j;
men:=true;
break;
end;
read(a);read(a);
end;
for i:= 0 to m+1 do begin
house[0,i]:='#';
house[n+1,i]:='#';
end;
for i:= 0 to n+1 do begin
house[i,0]:='#';
house[i,m+1]:='#';
end;
search(xx,yy);
writeln(tot);
readln(m,n);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator