Where is my error?
Posted by
Anton 12 Jun 2002 23:38
-----------------------My program-------------------------------------
const q = 40;
var
counter,check,l,i,j,n:integer;
s:string;
a:array [1..q,1..q] of integer;
ch:string;
begin
readln (n);
for i:=1 to n do
begin
for l:=1 to N DO
begin
readln (ch);
if ch='.' then
begin
a[i,l]:=1
end
else a[i,l]:=-1;
end;
end;
a[1,1]:=2;
a[n,n]:=2;
check:=1;
while (check=1) do
begin
check:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
if a[i,j]=2 then
begin
a[i,j]:=3;
if a[i-1,j]=1 then a[i-1,j]:=2;
if a[i,j-1]=1 then a[i,j-1]:=2;
if a[i+1,j]=1 then a[i+1,j]:=2;
if a[i,j+1]=1 then a[i,j+1]:=2;
check:=1;
end;
end;
end;
end;
for i:=1 to n do
begin
for j:=1 to n do
begin
if a[i,j]=3 then
begin
if (a[i-1,j]<>3) then inc (counter);
if (a[i+1,j]<>3) then inc (counter);
if (a[i,j+1]<>3) then inc (counter);
if (a[i,j-1]<>3) then inc (counter);
end;
end;
end;
counter:=counter-4;
writeln (counter*9);
end.
{Where is my error? I have WA}