Recent

Author Topic: [Updated] Please help me to solve it!!!  (Read 6758 times)

W

  • Newbie
  • Posts: 6
[Updated] Please help me to solve it!!!
« on: May 28, 2015, 04:07:03 pm »
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.jpg
http://i.imgur.com/mVqOqRo.jpg

The 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!!!!  %)
« Last Edit: May 29, 2015, 12:42:32 pm by W »

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: Please help me to solve it!!! Urgent!!!!
« Reply #1 on: May 28, 2015, 04:14:49 pm »
as this is an assignment for you to learn, what you can do is to start adding comments to the code about what the program is doing.
this will help you see what is missing.
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

W

  • Newbie
  • Posts: 6
Re: Please help me to solve it!!! Urgent!!!!
« Reply #2 on: May 28, 2015, 04:28:47 pm »
as this is an assignment for you to learn, what you can do is to start adding comments to the code about what the program is doing.
this will help you see what is missing.

All right, thanks for your reminding!

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Please help me to solve it!!! Urgent!!!!
« Reply #3 on: May 28, 2015, 04:38:40 pm »
Let's trade. You donate $10 usd to Lazarus project - I do the task for you.

eny

  • Hero Member
  • *****
  • Posts: 1634
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

W

  • Newbie
  • Posts: 6
Re: Please help me to solve it!!! Urgent!!!!
« Reply #5 on: May 28, 2015, 05:07:42 pm »
Let's trade. You donate $10 usd to Lazarus project - I do the task for you.

Um... I'd study it myself rather than trading. I will consider donating when I become affordable on it.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Please help me to solve it!!! Urgent!!!!
« Reply #6 on: May 28, 2015, 05:17:03 pm »
Um... I'd study it myself rather than trading. I will consider donating when I become affordable on it.
Ok. but then you need to define "HELP".

In other words, you need to define the exact point of where you don't understand what needs to be updated in the teacher's code.

Read the explanation from PDFs and try to track it in the pascal code provided.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Please help me to solve it!!! Urgent!!!!
« Reply #7 on: May 28, 2015, 05:19:37 pm »
the algorithm is actually given here

W

  • Newbie
  • Posts: 6
Re: Please help me to solve it!!! Urgent!!!!
« Reply #8 on: May 28, 2015, 05:25:40 pm »
Um... I'd study it myself rather than trading. I will consider donating when I become affordable on it.
Ok. but then you need to define "HELP".

In other words, you need to define the exact point of where you don't understand what needs to be updated in the teacher's code.

Read the explanation from PDFs and try to track it in the pascal code provided.

Well... This is the first time I write this program, I think the main difficulty is to solve the errors detected by Bloodshed Dev-Pascal first.
But I can't find what exactly I need to modify, so I think I'd better to do it myself.
What I'm asking for help is hope you can teach me what need to be filled in the ??? in the code.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Please help me to solve it!!! Urgent!!!!
« Reply #9 on: May 28, 2015, 05:29:18 pm »
The teacher wrote some part for us...
Unfortunately you were given a very messy template program that violates many programming paradigms...  :(
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Please help me to solve it!!! Urgent!!!!
« Reply #10 on: May 28, 2015, 05:33:25 pm »
What I'm asking for help is hope you can teach me what need to be filled in the ??? in the code.
the place where ??? is used is supposed to populate each cell in newcells arrays. That means that both ??? should go through all visible cells.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Please help me to solve it!!! Urgent!!!!
« Reply #11 on: May 28, 2015, 05:35:15 pm »
Unfortunately you were given a very messy template program that violates many programming paradigms...  :(
Well, no. It follows educational language paradigm.

a single instance of function (procedure) declaration makes a task unsolvable for majority of students :)
« Last Edit: May 28, 2015, 05:37:06 pm by skalogryz »

W

  • Newbie
  • Posts: 6
Re: Please help me to solve it!!! Urgent!!!!
« Reply #12 on: May 28, 2015, 05:40:01 pm »
What I'm asking for help is hope you can teach me what need to be filled in the ??? in the code.
the place where ??? is used is supposed to populate each cell in newcells arrays. That means that both ??? should go through all visible cells.

OK. Thanks a lot for your help!  :)

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: Please help me to solve it!!! Urgent!!!!
« Reply #13 on: May 28, 2015, 05:44:49 pm »
https://cs.brown.edu/courses/cs015/labs/Lab6Pseudocode.pdf

reading down to 'Drawing Turtles' may help.
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

W

  • Newbie
  • Posts: 6
Re: Please help me to solve it!!! Urgent!!!!
« Reply #14 on: May 28, 2015, 05:58:27 pm »
https://cs.brown.edu/courses/cs015/labs/Lab6Pseudocode.pdf

reading down to 'Drawing Turtles' may help.

Thanks. I'll try to look at it.

 

TinyPortal © 2005-2018