输入一列数字,求最大值

#! /usr/bin/perl -w

sub max {
  my($big)=shift @_;

  foreach (@_) {
    if ($big<$_) {
      $big=$_;
    }
  }
  $big
}
print "please input some numbers,and use Ctrl-D to end:\n";
chomp (@m=<STDIN>);
$n=&max(@m);
print "the maxmum number is:$n\n";

添加新评论 »