你是大牛吗

如果你是大牛,请框选下面

Program P1415;

type arr = array[1..100,1..100] of boolean;

var

n, m, t, i, j, k, s : longint;

a, b : arr;

ch : char;

begin

readln(m, n, t);

fillchar(a, sizeof(a), false);

for i := 1 to n do

begin

for j := 1 to m do

begin

read(ch);

if ch = '1' then a := true;

end;

readln;

end;

for i := 1 to t - 1 do

begin

b := a;

for j := 1 to n do

for k := 1 to m do

begin

s := 0;

if (j - 1 > 0) and (k - 1 > 0) then

if b[j-1, k-1] then inc(s);

if (j > 0) and (k - 1 > 0) then

if b[j, k-1] then inc(s);

if (j + 1 < n) and (k - 1 > 0) then

if b[j+1,k-1] then inc(s);

if (j - 1 > 0) and (k > 0) then

if b[j-1, k] then inc(s);

if (j < n) and (k > 0) then

if b[j+1, k] then inc(s);

if (j - 1 > 0) and (k < m) then

if b[j-1, k+1] then inc(s);

if (j > 0) and (k < m) then

if b[j, k+1] then inc(s);

if (j < n) and (k < m) then

if b[j+1, k+1] then inc(s);

if b[j, k] then

begin

if s < 2 then

a[j, k] := false;

if s > 3 then

a[j, k] := false;

if (s = 2) or (s = 3) then a[j, k] := true;

end

else

begin

if s = 3 then a[j, k] := true;

end;

end;

end;

for i := 1 to n do

begin

for j := 1 to m do

if a then write(1) else write(0);

writeln;

end;

end.

改改吧

3 条评论

  • @ 2016-12-21 19:00:45

    我是大牛,但我不会pascal,会C++.哈哈......

  • @ 2016-08-15 17:17:07

    我是大牛,但我不会pascal,哈哈

  • @ 2009-07-28 22:48:33

    我只是小菜……但可以看得出……你忘了更新a数组……Program P1415;type arr = array[1..100,1..100] of boolean;var n, m, t, i, j, k, s : longint; a, b : arr; ch : char;begin readln(m, n, t); fillchar(a, sizeof(a), false); for i := 1 to n do begin  for j := 1 to m do   begin   read(ch);   if ch = '1' then a := true;   end;  readln; end; for i := 1 to t - 1 do begin  b := a;  for j := 1 to n do   for k := 1 to m do   begin   s := 0;   if (j - 1 > 0) and (k - 1 > 0) then    if b[j-1, k-1] then inc(s);   if (j > 0) and (k - 1 > 0) then    if b[j, k-1] then inc(s);   if (j + 1 < n) and (k - 1 > 0) then    if b[j+1,k-1] then inc(s);   if (j - 1 > 0) and (k > 0) then    if b[j-1, k] then inc(s);   if (j < n) and (k > 0) then    if b[j+1, k] then inc(s);   if (j - 1 > 0) and (k < m) then    if b[j-1, k+1] then inc(s);   if (j > 0) and (k < m) then    if b[j, k+1] then inc(s);   if (j < n) and (k < m) then    if b[j+1, k+1] then inc(s);   if b[j, k] then    begin     if s < 2 then     a[j, k] := false;     if s > 3 then     a[j, k] := false;     if (s = 2) or (s = 3) then a[j, k] := true;    end   else    begin     if s = 3 then a[j, k] := true;    end;   end; end; a:=b; for i := 1 to n do begin  for j := 1 to m do   if a then write(1) else write(0);  writeln; end;end.

  • 1

信息

ID
1415
难度
6
分类
模拟 点击显示
标签
(无)
递交数
1864
已通过
514
通过率
28%
上传者