On Feb 1, sanilkumar said:
>This program is not working
That is the worst possible way to describe your program -- WHAT doesn't
work about it?! Do you get any error messages?
>print "Enter the num: of num: ";
>my $co=<STDIN>;
>for(my $i=0;$i<$co;$i++)
>{
> my $r=$i+1;
> print("Enter the $r number");
> local$a[$i]=<STDIN>;
Why are you using local() here? It's making you lose your data when the
loop ends.
>}
>$first=0;
>$last=$co;
>quicksort(\@a,$first,$last);
>system(clear);
That should be system("clear").
>print("\t@a");
>
>sub quicksort(\@$$)
DO NOT USE PROTOTYPES. That is sage advice.
>{
> my($num,$fi,$la)=@_;
> print("\t$fi");
> if($la > 0 && $fi!=$la)
> {
> my $pivot=$num->[$fi];
> my $spl=splitpoint(\@num,$fi,$la,$pivot);
> my $wi = $spl-1;
> my $ww = $spl+1;
> if($wi > $fi)
> {
> quicksort(\@num,$fi,$wi);
> }
> if($ww < $la)
> {
> quicksort(\@num,$ww,$la);
> }
> }
>}
>sub splitpoint(\@$$$)
DO NOT USE PROTOTYPES. That is sage advice.
>{
> my($num,$fn,$ln,$pi)=@_;
> do
> {
> while($num->[$fn] < $pi)
> {
> $fn=$fn+1;
> }
> while($num->[$ln] > $pi)
> {
> $ln=$ln-1;
> }
> if($fn<$ln)
> {
> @{ $num }[$fn, $ln] = @{ $num }[$ln, $fn];
> }
> }while($fn < $ln);
>return($fn);
>}
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]