/** * @param Difference $difference */ public function __construct(Difference $difference) { $this->bitmap = $difference->getBitmap(); $this->width = $difference->getWidth(); $this->height = $difference->getHeight(); $this->boundaries = $this->findBoundaries(); }
{ private $elements = array(); public $maximumDifference; function __construct($arr) { $this->elements =& $arr; } public function computeDifference() { $min = $this->elements[0]; $max = $this->elements[0]; foreach ($this->elements as $value) { if ($value < $min) { $min = $value; } if ($value > $max) { $max = $value; } } $this->maximumDifference = $min - $max; if ($this->maximumDifference < 0) { $this->maximumDifference *= -1; } } } //End of Difference class $N = intval(fgets(STDIN)); $a = array_map('intval', explode(' ', fgets(STDIN))); $d = new Difference($a); $d->ComputeDifference(); print $d->maximumDifference;