Advertisement
elektryk798

JAO2_PHP

Oct 23rd, 2017
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  
  5. {x1,x2,x3,x4}
  6. {y1,y2,y3,y4,y5}
  7.  
  8. */
  9. require_once "./ProgramJAO.php";
  10.  
  11. $program = new ProgramJAO();
  12. $program->main();
  13. print_r($program->wynik);
  14. $zbiory = $program->wynik;
  15. echo "<br>";
  16. //echo "<br>".count($zbiory)."<br>";
  17.  
  18. //SUMA
  19. $suma = $zbiory[0];
  20. print_r($suma);
  21. echo "<br>SUMA: ";
  22. for ($i=1;$i<count($zbiory);$i++)
  23. {
  24. foreach ($zbiory[$i] as $element)
  25. {
  26. if(!(in_array($element,$suma)))
  27. $suma[]=$element;
  28. }
  29. }
  30. print_r($suma);
  31. //SUMA_END
  32.  
  33. //ROZNICA
  34. $roznica = $zbiory[0];
  35. echo "<p>ROZNICA START: ";print_r($roznica);echo "<br>";
  36. for ($i=1;$i<count($zbiory);$i++)
  37. {
  38. foreach ($zbiory[$i] as $element)
  39. {
  40. foreach ($roznica as $test)
  41. {
  42. if($test === $element)
  43. {
  44.  
  45. array_splice($roznica,array_search($test, $roznica),1);
  46. }
  47.  
  48. }
  49. }
  50. }
  51. echo "<br>ROZNICA: ";
  52. print_r($roznica);
  53. //ROZNICA_END
  54.  
  55. //ILOCZYN
  56. $iloczyn = array_intersect($zbiory[0],$zbiory[1]);
  57. echo "<p>ILOCZYN START: ";print_r($iloczyn);echo "<br>";
  58. for ($i=2;$i<count($zbiory);$i++)
  59. $iloczyn=array_intersect($iloczyn,$zbiory[$i]);
  60. echo "<br>ILOCZYN: ";
  61. print_r($iloczyn);
  62. //ILOCZYN_END
  63.  
  64. //GREATEST
  65. $suma_tmp = $zbiory[0];
  66. for ($i=1;$i<count($zbiory);$i++)
  67. {
  68. foreach ($zbiory[$i] as $element)
  69. {
  70. if(!(in_array($element,$suma_tmp)))
  71. $suma_tmp[]=$element;
  72. }
  73. }
  74. asort($suma_tmp);
  75. echo "<p>";
  76. print_r($suma_tmp);
  77. echo "<p>NAJWIEKSZY: ".end($suma_tmp)."<br>";
  78. //GREATEST_END
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement