彪彪
openkore
全部博文(50)
C编程(0)
软件工具(0)
c++入门(2)
openkore(0)
2010年(38)
2009年(12)
kevin258
wsy52081
ddmumahh
vincerma
raveh
mwx1234
chen_xue
zjwmv
zpbobo11
分类:
2009-12-09 13:46:40
#!user/bin/perluse strict;#function to return the average number of the array ;sub average {my (@num) = @_;my $num = scalar @num;my $total;foreach (0..$#num) {$total += $num[$_];}return ($total/$num);}#function to search the number of the array;sub above_average {my (@arry) = @_;my $average = average(@arry);my @num;foreach (0..$#arry){ push(@num,$arry[$_]) if ($arry[$_] >= $average);}return @num;}#test the submy @fred = above_average(1..10);print "\@fred is @fred \n";#test twomy @barney = above_average(100,1..10);print "\@barney is \n".join "\t",@barney,"\n";<STDIN>;
上一篇:perl基础练习
下一篇:PERL 二维数组排序
登录 注册