求助da lao

P1162 填涂颜色

###gezhongmeng
by ybwwbfjzy @ 2017-10-04 16:29:16


var a:array[1..100,1..100]of longword;n,i,j:longword;s:string;procedure fl(x,y:longword); begin if(x<1)or(x>n)or(y<1)or(y>n)then exit;if a[x,y]<>2 then exit;a[x,y]:=0; ```cpp fl(x+1,y);fl(x-1,y);fl(x,y+1);fl(x,y-1);end; begin readln(n);for i:=1 to n do begin for j:=1 to n do read(a[i,j]);readln;end; for i:=1 to n do for j:=1 to n do if a[i,j]=0 then a[i,j]:=2; for i:=1 to n do begin fl(i,1);fl(i,n);fl(1,i);fl(n,i);end; for i:=1 to n do begin for j:=1 to n do write(a[i,j],' ');writeln;end;end. ```
by WendY3027 @ 2017-10-05 20:32:48


|