develooper Front page | perl.beginners | Postings from February 2002

Generating for loop paterns HELP!

Thread Previous
From:
Bruce Ambraal
Date:
February 13, 2002 23:24
Subject:
Generating for loop paterns HELP!
Message ID:
sc6b8214.008@cct.org.za
Hi

 I have done (b) for coding see below, could someone assist with
(a)  (b) (d)

#!/usr/local/bin/perl -w
my $num_rows;
my $i;
my $r;


$num_rows = <STDIN>;

for ($r = 1; $r <= $num_rows; $r++)
    {
     for ($i=1; $i<= $r; $i++) {print ("  \n");}
         for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print ("  * ");}
    }# end for
print ("  \n");

solution:
-------------

5

  *   *   *   *   *

  *   *   *   *


  *   *   *



  *   *




  *


Thanks 
Bruce

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About