Code:
var f:text;
a:array[1..100,1..100] of boolean;
i,j,m,n:byte;
k:integer;
procedure Enter;
var f:text;
i,j:byte;
c:byte;
begin
assign(f,'antoan.inp');
reset(f);
readln(f,m,n);
for i:=1 to m do
for j:=1 to n do
begin
read(f,c);
if c=1 then a[i,j]:=true else a[i,j]:=false;
end;
close(f);
end;
begin
k:=0;
Enter;
assign(f,'antoan.out');
rewrite(f);
for i:=2 to m-1 do
for j:=2 to n-1 do
if (not a[i,j]) and a[i+1,j] and a[i-1,j] and a[i+1,j-1] and
a[i+1,j+1] and a[i-1,j-1] and a[i-1,j+1] and a[i,j-1] and
a[i,j+1] then
begin
writeln(f,i,' ',j);
k:=k+1;
end;
if k=0 then k:=-1;
write(f,k);
close(f);
readln
end.
Phần gán dữ liệu từ ma trận sang mảng 2 chiều ở thủ tục Enter
Được gửi bởi
1hakunamatata
bạn có thể viết cho mình toàn bộ đoạn code của bạn dk không. Đọc khó hiểu quá ah.
Đọc toàn bộ code thì phải khó hiểu hơn chứ
Bookmarks