作者gigantic30 (gigantic30)
看板Perl
標題[問題] 問一下哪裡語法錯誤?
時間Wed Oct 8 00:04:46 2008
這是我第一次寫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
1F:→ shelling:這是交大這學期 PL 作業? XD 10/08 10:29