Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. class OperacjeNaZbiorach {
  2. private $Zbiory = array();
  3. private $Wynik;
  4. public function getZbiory() {return $this->Zbiory;}
  5. public function setZbiory($zbiory) {$this->Zbiory = $zbiory;}
  6. public function getWynik() {return $this->Wynik;}
  7. public function setWynik() {$this->Wynik = $zbiory;}
  8. public function Max()
  9. {
  10. $Suma = $this->Zbiory[0];
  11. for($i=1; $i<count($this->Zbiory);$i++)
  12. {
  13. $Suma = array_merge($Suma,$this->Zbiory[$i]);
  14. }
  15. $n = count($Suma);
  16. $i = 0;
  17. for($i; $i<$n; $i++)
  18. {
  19. $j = 0;
  20. for($j; $j<$n-$i-1; $j++)
  21. {
  22. if($Suma[$j] > $Suma[$j+1])
  23. {
  24. $temp = $Suma[$j];
  25. $Suma[$j] = $Suma[$j+1];
  26. $Suma[$j+1] = $temp;
  27. }
  28. }
  29. }
  30. return $Suma[$n-1];
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. /////////////////////////////////////////////////////////////////
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. require_once './OdczytDanych.php';
  48. require_once './OperacjeNaZbiorach.php';
  49.  
  50. class ProgramJAO {
  51. //put your code here
  52. public $wynik;
  53. public function main()
  54. {
  55. $Odczyt_danych = new OdczytDanych(); // P.1
  56. $Odczyt_danych->setNazwaPliku("dane.txt"); // P.2
  57. $Odczyt_danych->Odczytaj(); // P.3
  58. $Zbiory = $Odczyt_danych->getZbiory(); //P.4
  59. $Op_na_zb = new OperacjeNaZbiorach(); // P.5
  60. $Op_na_zb ->setZbiory($Zbiory); // P.6
  61. echo $Op_na_zb->Max();// P.7
  62. $this->wynik = $Op_na_zb ->getWynik(); // P.8
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement