Differences

This shows you the differences between two versions of the page.

Link to this comparison view

amdelf_uppg12 [2016-11-21 15:09]
Anders Mosshäll created
amdelf_uppg12 [2017-09-01 14:54]
Line 1: Line 1:
-====== Lösningsförslag - Uppgift 12 ====== 
-<code php> 
- 
-<?php 
-include('head.php');                   
- 
-$arr = array (41, 5, 26, 2, 88, 9, 38, 67, 14, 30, 25, 44, 11, 94, 58); 
- 
-sort($arr); // Sortera för att skriva ut kombinationerna i storlektsordning 
- 
-$x = 0; 
-while ($x < count($arr)){   // Loopa igenom arrayen 
-  $y = $x + 1;              // Testa alla tal efter position $x 
-  while ($y < count($arr)){ 
-    $z = $y + 1;            // Testa alla tal efter position $y 
-    while ($z < count($arr)){ 
-       
-      if ($arr[$x] + $arr[$y] + $arr[$z] == 97){ // Summan 97? 
-        echo $arr[$x] . ' + ' .$arr[$y] . ' + ' . $arr[$z] .' = 97<br />'; 
-      } 
-       
-      $z++; 
-    }  
-    $y++; 
-  } 
-  $x++; 
-} 
- 
- 
-include('foot.php'); 
-?> 
- 
-</code> 
-