Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="lt">
- <head>
- <title>Kontrolinis 1 Variantas</title>
- <meta charset="utf-8">
- </head>
- <body>
- <h2>Julijos kolis</h2>
- <h3>1 Užduotis - temperatūros</h3>
- <?php
- // Masyve saugomas kiekvieno metų mėnesio temp. vidurkis.
- // Parašykite funckiją, kuri sugeneruotų atsitiktinę mėnesio temp. [-2;15]...
- // Čia padaryta, kad išvestų temp. didesnes už 10 per metus.
- $temp = array();
- $n = 12;
- $mins = 0;
- $maxs = 0;
- $men = 0;
- //$vidutine = 0;
- $men = array();
- $sk = 0;
- function randata($mins,$maxs){
- $randtemp = 0;
- $randtemp = rand($mins, $maxs);
- return $randtemp ;
- }
- function isrinkti($temp){
- for($j=0; $j< 12; $j++){
- $t = $temp[$j];
- $men = ($j+1);
- //$vidutine = ($temp/12);
- //echo "Vidutinė metų temp. yra ".$vidutine."<br>";
- if($t > 10) echo $t." C; Men: ".$men."<br>";
- }
- }
- for($x=0; $x < $n; $x++){
- $men = $x;
- if($x<3){
- $temp[$x] = randata(-2,15);
- }
- else if($x>=3 && $x<6){
- $temp[$x] = randata(15,35);
- }
- else if($x>=6 && $x<9){
- $temp[$x] = randata(10,-2);
- }
- else if($x>=9 && $x<12){
- $temp[$x] = randata(-30,0);
- }
- else $temp[$x] = "Belekas";
- }
- isrinkti($temp);
- ?>
- <hr>
- <h3>2 Užduotis - matricos</h3>
- <?php
- // Failo duom.txt pirmoje eilutėje parašytas kvadratinės matricos dydis.
- // Toliau surašytos dviejų matricų elementų reikšmės. Daugyba.
- $ran = rand(-5,5);
- echo $ran."<br><br>";
- $file = "duom.txt";
- $cont = file_get_contents($file);
- $cont = str_replace("\n", " ", $cont);
- $skaiciai = explode(" ", $cont);
- $eil = $skaiciai[0];
- $stulp = $skaiciai[1];
- $eil = (int)$eil;
- $stulp = (int)$stulp;
- $n = $eil*$stulp;
- for($x = 2;$x<$n+2; $x++){
- $skaiciai[$x] = (int)$skaiciai[$x];
- $skaiciai[$x]*=$ran;
- }
- $rez = "";
- $ind = 2;
- for($i = 0; $i< $eil;$i++){
- for($j = 0; $j < $stulp;$j++){
- $rez .= $skaiciai[$ind++]. " ";
- }
- $rez .= "\n";
- }
- file_put_contents("rez.txt", $rez);
- ?>
- <hr>
- <h3>3 Užduotis - mašinos</h3>
- <?php
- // Inicilizuoja dvimatį masyvą su metais. Išveda mašinų modelius
- // naujesnius už 2008 m.
- $cars = array(
- 'AlfaRomeo' => array(
- '156' => 2006,
- '159' => 2007,
- 'Brera' => 2007,
- 'Gulietta' => 2018
- ),
- 'Opel' => array(
- 'Astra' => 2012,
- 'Signum' => 2002,
- 'Corsa' => 1997,
- 'Ampera' => 2018
- ),
- 'Audi' => array(
- 'Bulka' => 1997,
- 'BulkaII' => 2002,
- 'BAulkaIII' => 2004,
- 'BulkaIV' => 2009
- )
- );
- foreach($cars as $brand => $brcars){
- krsort($brcars);
- foreach($brcars as $model => $year){
- $y = (int)$year;
- if($y > 2008) echo $model."<br>";
- }
- }
- ?>
- <hr>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement