Please help me to solve it!!!

Discussion in 'Scripting' started by wjy, May 28, 2015.

Tags:
  1. wjy

    wjy MDL Novice

    Dec 6, 2014
    48
    23
    0
    Scan.jpg Scan2.jpg
    And the teacher gave us this stuff:
    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 help me!!! Urgent!!!!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. endbase

    endbase MDL Guru

    Aug 12, 2012
    3,681
    1,009
    120
    If it's for school you gotta solve it yourself other wise you don't learn much from it ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. wjy

    wjy MDL Novice

    Dec 6, 2014
    48
    23
    0
    OK. Got it. Thanks. :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...