# 求大神点拨 找了很久不知道代码哪错了（编译不成功）

var
n,m,i,j:integer;
ge:array[1..100,1..100]of char;

function search(n1,m1:integer):integer;
var
i1,j1,t:integer;
begin
t:=0;
for i1:=n1-1 to n1+1 do
for j1:=m1-1 to m1+1 do
if ge[i1,j1]='*'
then
t:=t+1;
exit(t); end;
begin

for i:=1 to n do
for j:=1 to m do

for i:=1 to n do
for j:=1 to m do
if ge[i,j]='?' then
ge[i,j]:=chr(ord('0')+search(i,j)）;

for i:=1 to n do
for j:=1 to m do

write(ge[i,j]);
end.

# 1 条评论

• @ 2016-09-27 20:01:46

你写得好乱,读入有错误,输出有错误,数组应该开到0.......

代码附上,自己改改
var a,b,f:array[0..1000,0..1000]of longint;
i,j,l,n,m,t:longint; c:char;
function check(x,y:longint):longint;
var i,j,k:longint;
begin
k:=0;
for i:=x-1 to x+1 do
for j:=y-1 to y+1 do
if a[i,j]=1 then inc(k);
if a[x,y]=1 then dec(k);
exit(k);
end;
begin
for i:=1 to n do
begin
for j:=1 to m do
begin
if c='*' then a[i,j]:=1 else a[i,j]:=0;
end;
end;
for i:=1 to n do
for j:=1 to m do
f[i,j]:=check(i,j);
for i:=1 to n do
begin
for j:=1 to m do
if a[i,j]=1 then write('*') else write(f[i,j]);
writeln;
end;
end.

• 1

ID
1975

4

2813

1086

39%

20