fork download
  1. <?php
  2.  
  3. function divideEtImpera($arr, $left, $right) {
  4.  
  5. if($left == $right) {
  6.  
  7. return $arr[ $left ];
  8.  
  9. } else {
  10.  
  11. $m = ($left + $right) >> 1;
  12. $a = divideEtImpera($arr, $left, $m);
  13. $b = divideEtImpera($arr, $m + 1, $right);
  14. if($a > $b) return $a;
  15. else
  16. return $b;
  17. }
  18.  
  19. }
  20.  
  21. $arr = array(10,20,2021,101,90,92,91,41);
  22.  
  23. $max = divideEtImpera($arr, 0, sizeof($arr));
  24.  
  25. echo$max;
  26.  
  27. ?>
Success #stdin #stdout #stderr 0.03s 25820KB
stdin
Standard input is empty
stdout
2021
stderr
PHP Notice:  Undefined offset: 8 in /home/d9HjdH/prog.php on line 7