Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How can I find the index of the biggest element in an array?

by tye (Sage)
on Mar 08, 2001 at 11:03 UTC ( [id://62930]=note: print w/replies, xml ) Need Help??


in reply to How can I find the index of the biggest element in an array?

my $index = 0; my $maxval = $myarray[ $index ]; for my $i ( 0 .. $#myarray ) { $maxval < $myarray[$i] and $index = $i if $maxval < $myarray[$i]; } print "The greatest is element number $index: $myarray[$index]\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://62930]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found