Created
October 10, 2011 13:14
-
-
Save ctfliblime/1275289 to your computer and use it in GitHub Desktop.
This one will work on Perl 5.8 (and probably much earlier)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict ; | |
use warnings; | |
use locale ; | |
my @table=(1,2,3,8,5,8,0,4) ; | |
my @places ; | |
# Max value | |
my $max = (sort @table)[-1]; | |
# Position | |
for my $index (0..$#table) { | |
push @places, $index if $table[$index] == $max; | |
} | |
print "Max value is \"$max\", at position(s) " . join(", ", @places) . "\n" ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment