perl 小练习

perl 小练习,第1张

概述!/usr/bin/perl $subject={         math=>{                 "mahong"=>90,                 "mahao"=>98,                 "zhangwei"=>89,                 "yawei"=>98         },         chinese=>{          

!/usr/bin/perl $subject={         math=>{                 "mahong"=>90,                "mahao"=>98,                "zhangwei"=>89,                "yawei"=>98         },        chinese=>{                 "mahong"=>90,                "mahao"=>97,                "zhangwei"=>98,                "yawei"=>100         },}; print "Keys of subject:\n"; foreach $key (keys %{$subject}){                 print $key . "\n"; } print "Keys of math:\n"; foreach $key (keys %{$subject->{math}}){                 print $key . "\n"; } print "The best grade in math:\n"; foreach $key (keys %{$subject->{math}}){                 push @tmp,$subject->{math}->{$key}; } #求单科成绩最优 sub max{         my @tmp=@_;         $max=$_; foreach (@tmp){                 if ($max <$_){                 $max = $_;                 }         }         return $max; } $max_score=&max(@tmp); #求单科成绩最优者 print $max_score. "\n"; foreach $key (keys %{$subject->{math}}){                 if ($subject->{math}->{$key} == $max_score) {                         print $key ."is good!!!\n";                 } }  

总结

以上是内存溢出为你收集整理的perl 小练习全部内容,希望文章能够帮你解决perl 小练习所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1283921.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存