- 扫雷游戏
- 2016-07-13 16:19:47 @
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
readln(n,m);
for i:=1 to n do
for j:=1 to m do
read(ge[i,j]);
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 条评论
-
破军武帝 LV 8 @ 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
readln(n,m);
for i:=1 to n do
begin
for j:=1 to m do
begin
read(c);
if c='*' then a[i,j]:=1 else a[i,j]:=0;
end;
readln;
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