Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OperacjeNaZbiorach {
- private $Zbiory = array();
- private $Wynik;
- public function getZbiory() {return $this->Zbiory;}
- public function setZbiory($zbiory) {$this->Zbiory = $zbiory;}
- public function getWynik() {return $this->Wynik;}
- public function setWynik() {$this->Wynik = $zbiory;}
- public function Max()
- {
- $Suma = $this->Zbiory[0];
- for($i=1; $i<count($this->Zbiory);$i++)
- {
- $Suma = array_merge($Suma,$this->Zbiory[$i]);
- }
- $n = count($Suma);
- $i = 0;
- for($i; $i<$n; $i++)
- {
- $j = 0;
- for($j; $j<$n-$i-1; $j++)
- {
- if($Suma[$j] > $Suma[$j+1])
- {
- $temp = $Suma[$j];
- $Suma[$j] = $Suma[$j+1];
- $Suma[$j+1] = $temp;
- }
- }
- }
- return $Suma[$n-1];
- }
- }
- /////////////////////////////////////////////////////////////////
- require_once './OdczytDanych.php';
- require_once './OperacjeNaZbiorach.php';
- class ProgramJAO {
- //put your code here
- public $wynik;
- public function main()
- {
- $Odczyt_danych = new OdczytDanych(); // P.1
- $Odczyt_danych->setNazwaPliku("dane.txt"); // P.2
- $Odczyt_danych->Odczytaj(); // P.3
- $Zbiory = $Odczyt_danych->getZbiory(); //P.4
- $Op_na_zb = new OperacjeNaZbiorach(); // P.5
- $Op_na_zb ->setZbiory($Zbiory); // P.6
- echo $Op_na_zb->Max();// P.7
- $this->wynik = $Op_na_zb ->getWynik(); // P.8
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement