program bai3_ovuong; const fi='SQUARE.INP'; fo='SQUARE.OUT'; var f:text; a,nga,doc:array[1..1000,1..1000] of integer; i,m,n,d,j:integer; procedure nhap; var i,j:integer; begin assign(f,fi); reset(f); readln(f,m,n); for i:=1 to m do begin for j:=1 to n-1 do read(f,nga[i,j]); readln(f); end; for i:=1 to m-1 do begin for j:=1 to n do read(f,doc[i,j]); readln(f); end; end; begin nhap; d:=0; for i:=1 to m-1 do for j:=1 to n-1 do if nga[i,j]+nga[i+1,j]+doc[i,j]+doc[i,j+1]=4 then inc(d); assign(f,fo); rewrite(f); write(f,d); close(f); write('Da ghi ghi ket qua vao file: ',fo); readln(); end.
FILE: SQUARE.INP
3 5 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1 0 0 1 1 0 0 0
Nosomovo