Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="lt">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Forma</title>
  6. </head>
  7. <body>
  8.  
  9. <h2>1 užd : Vidurkiai</h2>
  10.  
  11. <?php
  12.  
  13. arba $metai = array(
  14. "Pavasaris" => array(
  15. "Kovas" = rand(-2 ,15 ),
  16. "Kovas" = rand(-2 ,15 ),
  17. "Kovas" = rand(-2 ,15 ),
  18. ),
  19. "Pavasaris" => array(
  20. "Kovas" = rand(-2 ,15 ),
  21. "Kovas" = rand(-2 ,15 ),
  22. "Kovas" = rand(-2 ,15 ),
  23. ),
  24. "Pavasaris" => array(
  25. "Kovas" = rand(-2 ,15 ),
  26. "Kovas" = rand(-2 ,15 ),
  27. "Kovas" = rand(-2 ,15 ),
  28. ),
  29. "Pavasaris" => array(
  30. "Kovas" = rand(-2 ,15 ),
  31. "Kovas" = rand(-2 ,15 ),
  32. "Kovas" = rand(-2 ,15 ),
  33. ),
  34. )
  35. ir :
  36.  
  37. foreach metai as season => seasonVal
  38. foreach metai[season] as month => mVal
  39. if mVal>=10 {
  40. echo month, mVal
  41. }
  42. _____________________________
  43.  
  44. $pavasaris = rand(-2 ,15 );
  45. $ruduo = rand(10 ,-2 );
  46. $vasara = rand(15 ,35 );
  47. $ziema = rand(-30 ,0 );
  48. $vidurkis = array(
  49. "Pavasaris" => $pavasaris,
  50. "Ruduo" => $ruduo,
  51. "Vasara" => $vasara,
  52. "Žiema" => $ziema,
  53. );
  54. foreach ($vidurkis as $key => $val) {
  55. echo ''.$key.' : '.$val.' ,';
  56.  
  57. }
  58. echo '<hr>';
  59. foreach ($vidurkis as $key => $val) {
  60. if($val > 10 ) {
  61. echo ''.$key.' : '.$val.' , ';
  62. }
  63. }
  64. ?>
  65.  
  66. <h2>2 užd : Matricos</h2>
  67.  
  68. <?php
  69.  
  70. $file = "DUOMENYS.txt";
  71. $content = file_get_contents($file);
  72. $content = str_replace("\n", " ", $content);
  73. $arr = explode(" ", $content);
  74. print_r($arr);
  75.  
  76. $lines = $arr[0];
  77. $cols = $arr[1];
  78.  
  79. $count = $lines * $cols;
  80.  
  81. $randNum = rand(1,100);
  82.  
  83. for ($i = 2; $i < $count + 2; $i++) {
  84. $arr[$i] *= $randNum;
  85. }
  86.  
  87. echo "<br>";
  88. print_r($arr); // debug
  89.  
  90. $result = "";
  91.  
  92. $index = 2;
  93. for ($y = 0; $y < $lines; $y++) {
  94. for ($x = 0; $x < $cols; $x++) {
  95. $result .= $arr[$index++] . " ";
  96. }
  97. $result .= "\r\n";
  98. }
  99.  
  100. file_put_contents("rezultatai.txt", $result);
  101. ?>
  102.  
  103.  
  104. <h2>3 užd: Autos</h2>
  105. <?php
  106.  
  107. $data = array(
  108. "Ford" => array (
  109. "Focus" => 1996,
  110. "Hocus" => 2019,
  111. "Pocus" => 1997
  112. ),
  113.  
  114. "Audi" => array (
  115. "A6" => 2006,
  116. "A69" => 2020,
  117. "B20" => 1936
  118. ),
  119.  
  120. "Lamborghini" => array (
  121. "Gallardo" => 2001,
  122. "Ballardo" => 1950,
  123. "Ricardo" => 2010
  124. ),
  125.  
  126. "Volkswagen" => array (
  127. "Golf" => 2013,
  128. "Colf" => 2014,
  129. "Cholf" => 1984
  130. )
  131. );
  132.  
  133. foreach ($data as $mark => $markVal) {
  134. krsort($data[$mark]);
  135. }
  136.  
  137. echo "<pre>";
  138. print_r($data);
  139. echo "</pre>";
  140.  
  141. $result = "";
  142.  
  143.  
  144.  
  145. foreach ($data as $mark => $markVal) {
  146. foreach ($data[$mark] as $model => $modelVal) {
  147. if ($modelVal >= 2008) {
  148. $result .= $mark." ".$model." ".$modelVal;
  149. $result .= "\r\n";
  150. }
  151. }
  152. }
  153. echo $result;
  154. ?>
  155. </body>
  156. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement