ANKUR has asked for the wisdom of the Perl Monks concerning the following question:
HI
This is just another perl newbie here.Thanks every1 for replying to my question about merging files.
.Phew! i really do have a long way to go. Anyway i was going through some C exercises i had done previously and i came across an interesting
exercise. You have to write a program to produce
the following output
Well, um i wrote the code , but since er i just baby talk perl,
the code is very big i just know that there
is a more better and more intelligent way to do it
.I will really appreciate your help perl monks if you kindly
SHOW A BETTER WAY TO DO IT
THANKS ankur
This is just another perl newbie here.Thanks every1 for replying to my question about merging files.
.Phew! i really do have a long way to go. Anyway i was going through some C exercises i had done previously and i came across an interesting
exercise. You have to write a program to produce
the following output
Well, um i wrote the code , but since er i just baby talk perl,
the code is very big i just know that there
is a more better and more intelligent way to do it
.I will really appreciate your help perl monks if you kindly
SHOW A BETTER WAY TO DO IT
THANKS ankur
er i dont know formatting yetABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A <CODE> #!/usr/bin/perl -w @store=('a'..'g'); $i=@store; $count=0; while($i>=0){ &printline($i-1,@store); &revline($i-1,$count,@store); $count++; pop(@store); } sub printline{ ($itemp,@printarray)=@_; for($j=0;$j<=$itemp;$j++){ print "$printarray[$j]"; } } sub revline{ ($it,$cou,@linarray)=@_; if ($cou==0){ for($k=$it;$k>=0;$k--){ print "$linarray[$k]"; } print '/n'; return; } $p=$cou-1; $r=2*$p + 1; for ($j=1;$j<=$r;$j++){ print " "; } for($k=@linarray-1;$k>=0;$k--){ print "$store[$k]"; if ($k==0){ print '\n' ; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: outputting fun
by indigo (Scribe) on Aug 29, 2000 at 20:08 UTC | |
RE: outputting fun
by Shendal (Hermit) on Aug 29, 2000 at 19:51 UTC | |
Re: outputting fun
by Corion (Patriarch) on Aug 29, 2000 at 19:47 UTC | |
by lindex (Friar) on Aug 30, 2000 at 11:55 UTC | |
by stefp (Vicar) on Mar 28, 2001 at 00:10 UTC | |
Re: outputting fun
by Boogman (Scribe) on Aug 29, 2000 at 19:51 UTC | |
Re: outputting fun
by tye (Sage) on Aug 29, 2000 at 20:43 UTC | |
by mdillon (Priest) on Aug 29, 2000 at 20:59 UTC | |
Re: outputting fun
by cwest (Friar) on Aug 29, 2000 at 22:51 UTC | |
Re (tilly) 1: outputting fun
by tilly (Archbishop) on Mar 28, 2001 at 05:17 UTC | |
Re: outputting fun
by Arry (Initiate) on Jan 09, 2002 at 19:16 UTC |
Back to
Seekers of Perl Wisdom