|
@data = (0,3,1,2,4);
max(@data);
min(@data);
sub max()
{
my @numlist;
my $cur,$max=0;
@numlist = @_;
$cur = 0;
$max = 0;
foreach $num (@numlist)
{
$cur = $num;
if ( $cur > $max ) { $max = $cur; }
print "$num\n";
}
print "max = $max\n";
}
sub min()
{
my @numlist;
my $cur,$min=0;
@numlist = @_;
$cur = 0;
$max = 0;
foreach $num (@numlist)
{
$cur = $num;
if ( $cur < $min ) { $min = $cur; }
print "$num\n";
}
print "min = $min\n";
}
|
|