看板 Perl 關於我們 聯絡資訊
這是我第一次寫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
shelling:這是交大這學期 PL 作業? XD 10/08 10:29