######################### 1001 ##############################
use 5.010;while(<>){ my @num = split; say $num[0] + $num[1];}
######################### 1048 ##############################
my $n = 12;my $sum = 0;while ( $n -- ){ chomp(my $num = <STDIN>) ; $sum += $num;}printf "/$%.2f/n", $sum / 12 ;
######################### 1109 ##############################
use 5.010;my %hash;while(<STDIN>){ last if $_ eq "/n" ; my($value, $key) = split; $hash{$key} = $value;}while(<STDIN>){ chomp; exists $hash{$_} ? say "$hash{$_}" : say "eh";}
######################### 1151 ##############################
my $case = <STDIN>;for (1..$case){ chomp(my $n = <STDIN>); redo if $n eq ''; print "/n" if $_ != 1 ; for (1..$n){ chomp($_ = <STDIN>); my @arr = split; while(@arr){ print reverse split '', shift @arr; print " " if @arr ; #最後一行不加空格 } print "/n"; }}
######################### 1240 ############################
chomp(my $num = <STDIN>);my $nums = 1;while($num --){ chomp(my $str = <STDIN>); printf "String #%d/n",$nums++; my @arr = split("",$str); $str = shift @arr; while($str){ $str eq "Z" ? print "A" : print chr(ord($str)+1); $str = shift @arr; } print "/n/n";}
######################### 1241 ##############################
my $n = 1;while(<STDIN>){ my ($a,$b,$c) = split; last if $a + $b + $c == 0 ; printf "Triangle #%d/n",$n++; printf "c = %.3f",sqrt ($a**2 + $b**2 ) if $c == -1; $c > $a ? printf "b = %.3f",sqrt ($c**2 - $a**2 ):print "Impossible." if $b == -1; $c > $b ? printf "a = %.3f",sqrt ($c**2 - $b**2 ):print "Impossible." if $a == -1; print "/n/n";}
######################### 1608 ##############################
use 5.010;while(<>){ my($a, $b, $r1, $r2) = split; my $total_r= $r1 + $r2 ; (say "No") && next if $total_r > $a || $total_r >$b; sqrt(($a-$total_r)**2 + ($b-$total_r)**2) < $total_r ? say "No" : say "Yes";}
######################### 1808 ##############################
my $flag = 0;my $count = 1;my @arr;while (<STDIN>){ chomp; if ($_ == 9){ printf "Set %d is immediately decodable/n",$count++ if $flag != 1; $#arr = -1; $flag = 0; next; } next if $flag == 1; push @arr, $_; for(my $i =0; $i <= $#arr-1 && $flag != 1; $i++ ){ (printf "Set %d is not immediately decodable/n",$count++) && ($flag = 1) if /^$arr[$i]/ ; }}
-------------------------------------- Separate Line -----------------------------------------
說明幾點:1、題目和代碼都很簡單,所以代碼就沒有加註釋。2、如果代碼有錯誤或者可以改進的希望能告訴我一下,互相提高!3、共用是種美德 !