我擦
查看原帖
我擦
35
一碗粥楼主2013/9/19 23:19
var i,j,k1,k2,k3,k4,l,m,n,sum:longint;
    a:array[1..50,1..50]of longint;
begin
  read(n);
  for i:=1 to n do
  for j:=1 to n do read(a[i,j]);
  for i:=2 to n-2 do
  begin
    for j:=2 to n-2 do
    begin
      if a[i,j]=0 then
      begin
        for k1:=j downto 1 do
        begin
          if a[i,k1]=1 then begin inc(sum);break;end;
        end;
        for k2:=j to n do
        begin
          if a[i,k2]=1 then begin inc(sum);break;end;
        end;
        for k3:=i downto 1 do
        begin
          if a[k3,j]=1 then begin inc(sum);break;end;
        end;
        for k4:=i to n do
        begin
          if a[k4,j]=1 then begin inc(sum);break;end;
        end;
        if sum mod 4=0 then a[i,j]:=2;
      end;
    end;
  end;
  for i:=1 to n do
  begin
    for j:=1 to n do
    begin
      write(a[i,j],' ');
    end;
    writeln;
  end;
end.

本人垃圾一只 暴力 求解为什么只差一个数啊

@[url=/usershow?uid=32]洋葱头[/url]

@墨凝而至

@[url=/usershow?uid=11]vip999[/url]

@[url=/usershow?uid=51]YanjunchenEdward[/url]

@[url=/usershow?uid=38](Beta)857164819[/url]

2013/9/19 23:19
加载中...