|
|
back to boardCommon Boardwhy my program(1033) does not work ? { 1033 } const di :array [1..4] of integer = (0,0,1,-1); dj :array [1..4] of integer = (1,-1,0,0); var tab :array [0..34,0..34] of char; i,j,d,n,r: integer; op:boolean; begin for i:=0 to 34 do for j:=0 to 34 do tab[i,j]:='#'; readln(n); for i:=1 to n do begin for j:=1 to n do read(tab[i,j]); readln; end; tab[1,1]:='v'; op:=true; while op do begin op:=false; for i:=1 to n do for j:=1 to n do if tab[i,j]='v' then for d:=1 to 4 do if (i+di[d]>0) and (i+di[d]<=n) and (j+dj[d]>0) and (j+dj[d]<=n) and (tab[i+di[d],j+dj[d]]='.') then begin tab[i+di[d],j+dj[d]]:='v'; op:=true; end; end; r:=0; for i:=0 to n+1 do for j:=0 to n+1 do if tab[i,j]='#' then for d:=1 to 4 do if (i+di[d]>=0) and (i+di[d]<=n+1) and (j+dj[d]>=0) and (j+dj[d]<=n+1) and (tab[i+di[d],j+dj[d]]='v') then inc(r); r:=(r-4)*9; writeln(r); end. |
|
|