Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Help at making a tree trunk Posted by pvn on 25 Jan 2013 at 3:44 PM
Hello to all
I am a beginner is pascal and i am trying to make a tree trunk that grows acording to the rest of the tree.
I already made the tree itself (here it is):

program Isosceles;
Uses Crt;
var num_lines, line:Integer;
procedure printline (num_esp, num_ast:Integer);
const aster='*';
esp=' ';
var counter:Integer;
begin
for counter:=1 to num_esp do
write(esp);
for counter:=1 to num_ast do
write(aster);
writeln
end;
begin (*Main program*)
writeln ('Height of the tree= ');
readln(num_lines);
for line:=1 to num_lines do
printline(num_lines-line,2*line-1);
readln;
end.


But now i am stuck and cant figure out how to make the tree trunk

I <------This part i want it to grow as the tree gets bigger(this part needs to be added at the bottom of the tree).



Help would be much appreciated

ps:I am usig Dev-Pascal 1.9.2.

Report
Re: Help at making a tree trunk Posted by quikcarlx on 30 Jan 2013 at 1:33 PM
I altered your program so that your subroutine could be a little more flexible. I dont know how you wanted to do the trunk so I made some assumptions.
program Isosceles;

  Uses Crt;

  var
    num_lines, line : Integer;
    trnk_spcs : integer;

  procedure printline ( num_esp, num_ast : Integer; tt : char );

    const
      esp = ' ';

    var
      counter : Integer;

    begin

      for counter := 1 to num_esp do
        write( esp );

      for counter := 1 to num_ast do
        write( tt );

      writeln
    end;

  begin (* Main program *)
    writeln( 'Height of the tree= ' );
    readln( num_lines );

    for line := 1 to num_lines do
      printline( num_lines - line, 2 * line - 1, '*' );

    trnk_spcs := num_lines - 1;

    for line := 1 to 4 do
      printline( trnk_spcs, 2, '|' );

    readln
  end.

Report
Re: Help at making a tree trunk Posted by pvn on 16 Feb 2013 at 8:14 AM
Sorry but on my initial post i didnt explain myself to well, my bad.
quikcarlx i want the tree trunk to grow as the tree gets bigger i have made some progress:

program Isosceles;
Uses Crt;
var num_lines, line, temp:Integer;
procedure printline (num_space, num_ast:Integer);
const aster='*';
esp=' ';
var counter:Integer;
begin
for counter:=1 to num_space do
write(esp);
for counter:=1 to num_ast do
write(aster);
writeln
end;
Procedure trunk1;
const esp=' ';
trunk='I';
Var counter:Integer;
begin
for counter:=1 to num_lines-1 do
write(esp);
writeln(trunk);
end;
begin (*main program*)
writeln ('Height of the tree= ');
readln(num_lines);
for line:=1 to num_lines do
printline(num_lines-line,2*line-1);
for temp:=1 to num_lines do
trunk1;
readln;

end.


But i still havent figured out how to make the tree trunk get thicker as the tree gets bigger.

Sorry taking so long to reply
Report
Re: Help at making a tree trunk Posted by erintech yesterday at 1:06 PM
quickcartx could you please contact me regarding a pascal bug I need help with? dennis dot lamb at gmail
Report
Re: Help at making a tree trunk Posted by erintech yesterday at 1:08 PM
quickcartx could you please contact me regarding a pascal bug I need help with? dennis dot lamb at gmail
Report
Re: Help at making a tree trunk Posted by erintech yesterday at 1:12 PM
quikcartx could you please contact me regarding a bug in a piece of Pascal code I am experiencing? dennis dot lamb at gmail



 

Recent Jobs