Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dvprog_19 [2020-04-02 14:13] Daniel Viström |
dvprog_19 [2024-04-12 13:45] Daniel Viström |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Lösningsförslag till uppgift 4 (Bubblesort) ====== | ====== Lösningsförslag till uppgift 4 (Bubblesort) ====== | ||
- | |||
- | <php> | ||
- | /* | ||
Filen **bubblesort.php** \\ | Filen **bubblesort.php** \\ | ||
Line 55: | Line 52: | ||
</ | </ | ||
+ | |||
+ | |||
+ | <php> | ||
+ | /* | ||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | function my_bubblesort(& | ||
+ | $i = 0; | ||
+ | while ($i < count($a) - 1){ | ||
+ | |||
+ | $j = 0; | ||
+ | while ( ){ | ||
+ | if ( ){ | ||
+ | |||
+ | |||
+ | } | ||
+ | $j++; | ||
+ | } | ||
+ | $i++; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | **Huvudprogrammet** | ||
+ | <code php> | ||
+ | <?php | ||
+ | include ' | ||
+ | include ' | ||
+ | |||
+ | $arr = [5, | ||
+ | my_bubblesort($arr); | ||
+ | $i = 0; | ||
+ | while($i < count($arr)){ | ||
+ | echo $arr[$i] . ' '; | ||
+ | $i++; | ||
+ | } | ||
+ | echo '< | ||
+ | |||
+ | include ' | ||
+ | </ | ||
*/ | */ | ||
</ | </ | ||
+ | |||