洛谷 P2670 扫雷游戏

洛谷 P2670 扫雷游戏_第1张图片
优美的暴力

var
  a:array [0..101,0..101] of boolean;
  i,j,m,n,ii,jj,o:integer;
  g:char;
begin
   readln(m,n);
   fillchar(a,sizeof(a),false);
   for i:=1 to m do
       begin
          for j:=1 to n do
              begin
                 read(g);
                 if g='*' then a[i,j]:=true;
              end;
          readln;
       end;
     for i:=1 to m do
         begin
            for j:=1 to n do
                begin
                   if a[i,j]=false
                      then begin
                               o:=0;
                               for ii:=-1 to 1 do
                                   begin
                                      for jj:=-1 to 1 do
                                      if a[i+ii,j+jj] then o:=o+1;
                                   end;
                               write(o);
                           end
                      else write('*');
               end;
            writeln;
         end;
end.

你可能感兴趣的:(暴力/枚举/模拟,pascal)