This is an old revision of the document!
Lösningsförslag - Uppgift 12
<?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'); ?>