Hi Everyone had to crawl before they could walk, JON, stop being polite and help me I need your assistance now... Cheers Bruce
>>> Jon Molin <[EMAIL PROTECTED]> 02/14/02 12:00PM >>> This smells homework! /jon Bruce Ambraal wrote: > > 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 > > ------------------------------------------------------------------------ > > Subject: Help can't figure this one out > Date: Thu, 14 Feb 2002 08:24:11 +0200 > From: "Bruce Ambraal" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> > > I have written following coding to produce a triangle pattern(see below); > I now want to produce following paterns I can't figer this out > > (a) (b) (c) (d) diamond > * * * * * * * * * * * * > * * * * * * * * * * * * * > * * * * * * * * * * * * * > * * * * * * * * * * * * * > * * * * * * * * * * * > * * * > * > ______________________________________________ > #!/usr/local/bin/perl -w > my $num_rows; > my $i; > my $r; > > $num_rows = <STDIN>; > > for ($r = 1; $r <= $num_rows; $r++) > { > # indent by printing num_rows - r spaces > for ($i = 1; $i <= $num_rows - $r; $i++) {print (" \n");} > # print r asterisks > for ($i=1; $i<= $r; $i++) { print (" *");} > # drop cursor to a new line > print "\n"; > } > # end for > > ------------------------------------- > unxsup:/home/bruce$ perl triangle.pl > 5 > > * > > * * > > * * * > > * * * * > * * * * * > > Cheer > Bruce > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > ------------------------------------------------------------------------ > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]