[問題] 問一下哪裡語法錯誤?
這是我第一次寫perl, 請板上高手指點一下
謝謝^^
%h=(fib(0)=>1, fib(1)=>1);
sun fib
{
$h{fib($_[0])} = fib($_[0]-1)+fib($_[0]-2);
return $h{fib($_[0])};
}
print "Enter an integer>=0: ";
$n=<stdin>;
$ans=fib($n);
print "The $nth Fibonacci number is $ans";
print "\nBelow is the hash table created during the computation.\n"
foreach (keys %h){
print "$_=>$h{$_}\n";
}
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.196.69
→
10/08 10:29, , 1F
10/08 10:29, 1F
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章