Updated: Our teacher says that this assignment is just a challenge for us. He expected it is almost impossible for us to finish it. Thank you all for helping me!
Dear Pascal Professionals,
I have a homework about a hard Pascal coding for me. Can anyone help me?
http://i.imgur.com/6dmH4XW.jpghttp://i.imgur.com/mVqOqRo.jpgThe teacher wrote some part for us (also a Pascal file in the attachment):
uses crt;
var
i, j, rno, ratio, nb : integer;
oldcell, newcell : array[0..21, 0..41] of char;
cont : char;
begin
randomize;
writeln('Enter the initial percentage of living cells (0-100) : ');
readln(ratio);
for i := 0 to 21 do
for j := 0 to 41 do
newcell[i, j] := ' ';
for i := 1 to 20 do
for j := 1 to 40 do
begin
rno := random(100);
if rno < ratio then
newcell[i, j] := 'X'
end;
cont := 'Y';
while cont <> 'N' do
begin
clrscr;
for i := 1 to 20 do
begin
for j := 1 to 40 do
write(newcell[i,j]);
writeln
end;
for i := 1 to 20 do
for j := 1 to 40 do
oldcell[i,j] := newcell[i,j];
for i := ???
for j := ???
begin
nb := 0;
if oldcell[i-1, j-1] = 'X' then nb := nb + 1;
(* Missing statements here *)
end;
write('Continue (Y/N)?');
readln(cont)
end;
end.
Please!!! I need help!!!!