
I passed the sample but I still got WA
I need help
type
arr=array[1..10,1..10] of char;
var
a:arr;f,n:integer;
procedure ini(n:integer);
var
i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to n do
read(a[i,j]);
readln;
end;
end;
procedure main(var a:arr);
var
i,j,t:integer;
ch:char;
begin
f:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
read(ch);
if ch='x' then
if a[i,j]='*' then f:=1
else {if a[i,j]<>'*' then} begin
t:=0;
if ((i-1)>0)and((j-1)>0) then
if a[i-1,j-1]='*' then t:=t+1;
if ((i-1)>0)and(j>0) then
if a[i-1,j]='*' then t:=t+1;
if ((i-1)>0)and((j+1)<n+1) then
if a[i-1,j+1]='*' then t:=t+1;
if (i>0)and((j-1)>0) then
if a[i,j-1]='*' then t:=t+1;
if (i>0)and((j+1)<n+1) then
if a[i,j+1]='*' then t:=t+1;
if ((i+1)<n+1)and((j-1)>0) then
if a[i+1,j-1]='*' then t:=t+1;
if ((i+1)<n+1)and(j>0) then
if a[i+1,j]='*' then t:=t+1;
if ((i+1)<n+1)and((j+1)<n+1) then
if a[i+1,j+1]='*' then t:=t+1;
a[i,j]:=chr(t+ord('0'));
end
// else write('*');
end;
readln;
end;
end;
procedure print(a:arr);
var
i,j:integer;
begin
if f=1 then
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]);
writeln;
end
else for i:=1 to n do
begin
for j:=1 to n do
if a[i,j] in ['0'..'8']
then write(a[i,j])
else write('.');
writeln;
end;
end;
begin
readln(n);
ini(n);
main(a);
print(a);
readln;
end.[/pascal]