VBGRASS - Bãi cỏ ngon nhất
Tác giả: ladpro98
Ngôn ngữ: Pascal
program vbgrass;
uses math;
const fi='';
var a:array[1..101,1..101] of char;
r,c,res:longint;
procedure input;
var inp:text;
i,j:longint;
begin
assign(inp,fi);
reset(inp);
readln(inp,r,c);
for i:=1 to r do
begin
for j:=1 to c do
read(inp,a[i,j]);
readln(inp);
end;
close(inp);
end;
procedure process;
var i,j:longint;
begin
for i:=1 to r do
for j:=1 to c do
begin
if a[i,j] = '#' then
begin
inc(res);
if a[i,j+1] = '#' then
begin
a[i,j+1]:='.';
continue;
end;
if a[i+1,j] = '#' then
a[i+1,j]:='.';
end;
end;
end;
procedure output;
begin
write(res);
end;
begin
input;
process;
output;
end.