- 394 名前:デフォルトの名無しさん [2009/09/11(金) 07:53:17 ]
- >>387
ファインチューニングしてないけど、こんな感じ? sub bsearch($$;$$){ my ($a,$t,$s,$e)=@_; $s=$[ if !defined $s; $e=$#$a if !defined $e; &subroutine if $$a[$s] == $t; return $s if $s>=$e; $m=floor(($s+$e)/2); $x=bsearch($a,$t,$s,$m); $y=bsearch($a,$t,$m+1,$e); return ($a[$x]-$t < $a[$y]-$t) ? $x : $y; }
|

|